Class NSubstituteRegisterCallHandlerCommand
Sets up a substitute object's methods so that the return values will be retrieved from a fixture, instead of being created directly by NSubstitute.
This will setup any void/non-void virtual methods (including property getters and generics).
Inheritance
Implements
Inherited Members
Namespace: AutoFixture.AutoNSubstitute
Assembly: AutoFixture.AutoNSubstitute.dll
Syntax
public class NSubstituteRegisterCallHandlerCommand : ISpecimenCommand
Remarks
This will setup any void, non-void virtual methods. This includes:
- interface's methods/property getters;
- class's abstract/virtual/overridden/non-sealed methods/property getters;
Notes:
- Calling a method more than once with the same parameters will return the same value by default. To override that behavior pass a custom ICallResultCacheFactory instance.
- Methods inherited from System.Object are not set up due to a limitation in NSubstitute (http://stackoverflow.com/a/21787891).
Constructors
| Improve this Doc View SourceNSubstituteRegisterCallHandlerCommand(ISubstitutionContext)
Creates a new NSubstituteRegisterCallHandlerCommand instance with default ICallResultCacheFactory and ICallResultResolverFactory instances.
Declaration
public NSubstituteRegisterCallHandlerCommand(ISubstitutionContext substitutionContext)
Parameters
Type | Name | Description |
---|---|---|
ISubstitutionContext | substitutionContext |
NSubstituteRegisterCallHandlerCommand(ISubstitutionContext, ICallResultCacheFactory, ICallResultResolverFactory)
Creates an new NSubstituteRegisterCallHandlerCommand instance.
Declaration
public NSubstituteRegisterCallHandlerCommand(ISubstitutionContext substitutionContext, ICallResultCacheFactory callResultCacheFactory, ICallResultResolverFactory callResultResolverFactory)
Parameters
Type | Name | Description |
---|---|---|
ISubstitutionContext | substitutionContext | |
ICallResultCacheFactory | callResultCacheFactory | |
ICallResultResolverFactory | callResultResolverFactory |
Properties
| Improve this Doc View SourceCallResultCacheFactory
Factory used to create ICallResultCache instances.
Declaration
public ICallResultCacheFactory CallResultCacheFactory { get; }
Property Value
Type | Description |
---|---|
ICallResultCacheFactory |
CallResultResolverFactory
Factory used to create ICallResultResolver instances.
Declaration
public ICallResultResolverFactory CallResultResolverFactory { get; }
Property Value
Type | Description |
---|---|
ICallResultResolverFactory |
SubstitutionContext
The NSubstitute context.
Declaration
public ISubstitutionContext SubstitutionContext { get; }
Property Value
Type | Description |
---|---|
ISubstitutionContext |
Methods
| Improve this Doc View SourceExecute(Object, ISpecimenContext)
Registers a custom handler for the specified specimen if that is a substitute.
Custom handler resolves call result and ref/out arguments using the passed context
.
Declaration
public void Execute(object specimen, ISpecimenContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Object | specimen | |
ISpecimenContext | context |