public SubstituteState(ISubstitutionContext substitutionContext) { SubstitutionContext = substitutionContext; SubstituteFactory = substitutionContext.SubstituteFactory; SequenceNumberGenerator = substitutionContext.SequenceNumberGenerator; CallInfoFactory = new CallInfoFactory(); var callStack = new CallStack(); CallStack = callStack; ReceivedCalls = callStack; PendingSpecification = new PendingSpecification(); CallResults = new CallResults(CallInfoFactory); CallSpecificationFactory = NewCallSpecificationFactory(); CallActions = new CallActions(CallInfoFactory); PropertyHelper = new PropertyHelper(); ResultSetter = new ResultSetter(CallStack, PendingSpecification, CallResults, CallSpecificationFactory, CallActions); EventHandlerRegistry = new EventHandlerRegistry(); ReceivedCallsExceptionThrower = new ReceivedCallsExceptionThrower(); DefaultForType = new DefaultForType(); AutoValueProviders = new IAutoValueProvider[] { new AutoSubstituteProvider(SubstituteFactory), new AutoStringProvider(), new AutoArrayProvider(), #if NET4 new AutoTaskProvider(() => AutoValueProviders), #endif }; }
public SubstituteState(ISubstitutionContext substitutionContext, SubstituteConfig option) { SubstitutionContext = substitutionContext; SubstituteConfig = option; SequenceNumberGenerator = substitutionContext.SequenceNumberGenerator; var substituteFactory = substitutionContext.SubstituteFactory; var callInfoFactory = new CallInfoFactory(); var callStack = new CallStack(); CallStack = callStack; ReceivedCalls = callStack; PendingSpecification = new PendingSpecification(); CallResults = new CallResults(callInfoFactory); CallSpecificationFactory = CallSpecificationFactoryFactoryYesThatsRight.CreateCallSpecFactory(); CallActions = new CallActions(callInfoFactory); CallBaseExclusions = new CallBaseExclusions(); ResultsForType = new ResultsForType(callInfoFactory); var getCallSpec = new GetCallSpec(callStack, PendingSpecification, CallSpecificationFactory, CallActions); ConfigureCall = new ConfigureCall(CallResults, CallActions, getCallSpec); EventHandlerRegistry = new EventHandlerRegistry(); AutoValueProviders = new IAutoValueProvider[] { #if NET45 || NETSTANDARD1_5 new AutoObservableProvider(() => AutoValueProviders), new AutoQueryableProvider(), #endif new AutoSubstituteProvider(substituteFactory), new AutoStringProvider(), new AutoArrayProvider(), #if (NET4 || NET45 || NETSTANDARD1_5) new AutoTaskProvider(() => AutoValueProviders), #endif }; }
public SubstituteState(ISubstitutionContext substitutionContext, SubstituteConfig option) { SubstitutionContext = substitutionContext; SubstituteConfig = option; SequenceNumberGenerator = substitutionContext.SequenceNumberGenerator; var substituteFactory = substitutionContext.SubstituteFactory; var callInfoFactory = new CallInfoFactory(); var callCollection = new CallCollection(); CallCollection = callCollection; ReceivedCalls = callCollection; PendingSpecification = new PendingSpecification(substitutionContext); CallResults = new CallResults(callInfoFactory); AutoValuesCallResults = new CallResults(callInfoFactory); CallSpecificationFactory = CallSpecificationFactoryFactoryYesThatsRight.CreateCallSpecFactory(); CallActions = new CallActions(callInfoFactory); CallBaseExclusions = new CallBaseExclusions(); ResultsForType = new ResultsForType(callInfoFactory); CustomHandlers = new CustomHandlers(this); var getCallSpec = new GetCallSpec(callCollection, PendingSpecification, CallSpecificationFactory, CallActions); ConfigureCall = new ConfigureCall(CallResults, CallActions, getCallSpec); EventHandlerRegistry = new EventHandlerRegistry(); AutoValueProviders = new IAutoValueProvider[] { new AutoObservableProvider(() => AutoValueProviders), new AutoQueryableProvider(), new AutoSubstituteProvider(substituteFactory), new AutoStringProvider(), new AutoArrayProvider(), new AutoTaskProvider(() => AutoValueProviders), }; }
public SubstituteState(ISubstitutionContext substitutionContext) { SubstitutionContext = substitutionContext; SequenceNumberGenerator = substitutionContext.SequenceNumberGenerator; var substituteFactory = substitutionContext.SubstituteFactory; var callInfoFactory = new CallInfoFactory(); var callStack = new CallStack(); CallStack = callStack; ReceivedCalls = callStack; PendingSpecification = new PendingSpecification(); CallResults = new CallResults(callInfoFactory); CallSpecificationFactory = CallSpecificationFactoryFactoryYesThatsRight.CreateCallSpecFactory(); CallActions = new CallActions(callInfoFactory); var getCallSpec = new GetCallSpec(callStack, PendingSpecification, CallSpecificationFactory, CallActions); ConfigureCall = new ConfigureCall(CallResults, CallActions, getCallSpec); EventHandlerRegistry = new EventHandlerRegistry(); AutoValueProviders = new IAutoValueProvider[] { new AutoSubstituteProvider(substituteFactory), new AutoStringProvider(), new AutoArrayProvider(), #if NET4 new AutoTaskProvider(() => AutoValueProviders), #endif }; }
public override void Context() { base.Context(); ConfigureCall = mock <IConfigureCall>(); _call = mock <ICall>(); _call.stub(x => x.GetReturnType()).Return(_type); _firstAutoValueProvider = mock <IAutoValueProvider>(); _secondAutoValueProvider = mock <IAutoValueProvider>(); }
public override void Context() { base.Context(); _call = mock <ICall>(); _call.stub(x => x.GetReturnType()).Return(_type); _callResults = mock <ICallResults>(); _callSpecification = mock <ICallSpecification>(); _callSpecificationFactory = mock <ICallSpecificationFactory>(); _callSpecificationFactory.stub(x => x.CreateFrom(_call, MatchArgs.AsSpecifiedInCall)).Return(_callSpecification); _firstAutoValueProvider = mock <IAutoValueProvider>(); _secondAutoValueProvider = mock <IAutoValueProvider>(); }
private object GetResultValueUsingProvider(ICall call, Type type, IAutoValueProvider provider) { var valueToReturn = provider.GetValue(type); if (_autoValueBehaviour == AutoValueBehaviour.UseValueForSubsequentCalls) { var spec = _callSpecificationFactory.CreateFrom(call, MatchArgs.AsSpecifiedInCall); _callResults.SetResult(spec, new ReturnValue(valueToReturn)); } return(valueToReturn); }
public IReadOnlyCollection <IAutoValueProvider> CreateProviders(ISubstituteFactory substituteFactory) { IAutoValueProvider[] result = null; var lazyResult = new Lazy <IReadOnlyCollection <IAutoValueProvider> >( () => result ?? throw new InvalidOperationException("Value was not constructed yet."), LazyThreadSafetyMode.None); result = new IAutoValueProvider[] { new AutoObservableProvider(lazyResult), new AutoQueryableProvider(), new AutoSubstituteProvider(substituteFactory), new AutoStringProvider(), new AutoArrayProvider(), new AutoTaskProvider(lazyResult) }; return(result); }
public override void Context() { _testValuesProvider = mock <IAutoValueProvider>(); }