Beispiel #1
0
        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
            };
        }
 private object Create(Type[] typesToProxy, object[] constructorArguments, SubstituteConfig config)  
 {
     var callRouter = _callRouterFactory.Create(_context, config);
     var primaryProxyType = GetPrimaryProxyType(typesToProxy);
     var additionalTypes = typesToProxy.Where(x => x != primaryProxyType).ToArray();
     var proxy = _proxyFactory.GenerateProxy(callRouter, primaryProxyType, additionalTypes, constructorArguments);
     _callRouterResolver.Register(proxy, callRouter);
     return proxy;
 }
        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);
            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(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 ReturnFromBaseIfRequired(SubstituteConfig config, ICallBaseExclusions callBaseExclusions)
 {
     _required = config == SubstituteConfig.CallBaseByDefault;
     _callBaseExclusions = callBaseExclusions;
 }
Beispiel #5
0
 public ICallRouter Create(ISubstitutionContext substitutionContext, SubstituteConfig config)
 => new ElevatedCallRouter(new SubstituteState(substitutionContext, config), substitutionContext, new RouteFactory());
 public ICallRouter Create(ISubstitutionContext substitutionContext, SubstituteConfig config)
 {
     var substituteState = new SubstituteState(substitutionContext, config);
     return new CallRouter(substituteState, substitutionContext, new RouteFactory());
 }
Beispiel #7
0
 public ReturnFromBaseIfRequired(SubstituteConfig config, ICallBaseExclusions callBaseExclusions)
 {
     _required           = config == SubstituteConfig.CallBaseByDefault;
     _callBaseExclusions = callBaseExclusions;
 }
 public ICallRouter Create(ISubstitutionContext substitutionContext, SubstituteConfig config)
 {
     var state = new SubstituteState(substitutionContext, config);
     return new CallRouter(state, substitutionContext, new FluentQueryCompatibleRouteFactory());
 }
Beispiel #9
0
        public ICallRouter Create(ISubstitutionContext substitutionContext, SubstituteConfig config)
        {
            var substituteState = new SubstituteState(substitutionContext, config);

            return(new CallRouter(substituteState, substitutionContext, new RouteFactory()));
        }