Пример #1
0
        public static SubstituteState Create(ISubstitutionContext substitutionContext)
        {
            var substituteFactory = substitutionContext.SubstituteFactory;
            var callInfoFactory = new CallInfoFactory();
            var callStack = new CallStack();
            var pendingSpecification = new PendingSpecification();
            var callResults = new CallResults(callInfoFactory);
            var callSpecificationFactory = NewCallSpecificationFactory();
            var callActions = new CallActions(callInfoFactory);

            var callFormatter = new CallFormatter(new ArgumentsFormatter(new ArgumentFormatter()), new ArgumentFormatInfoFactory());

            var state = new object[]
            {
                callInfoFactory,
                callStack,
                pendingSpecification,
                callResults,
                callSpecificationFactory,
                substituteFactory,
                callActions,
                new PropertyHelper(),
                new ResultSetter(callStack, pendingSpecification, callResults, callSpecificationFactory, callActions),
                new EventHandlerRegistry(),
                new ReceivedCallsExceptionThrower(callFormatter),
                new DefaultForType(),
                new IAutoValueProvider[] { new AutoSubstituteProvider(substituteFactory), new AutoStringProvider(), new AutoArrayProvider()}
            };

            return new SubstituteState(state);
        }
Пример #2
0
        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),
            };
        }
Пример #3
0
        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
            };
        }
Пример #4
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
            };
        }
Пример #5
0
        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 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
            };
        }
Пример #7
0
        private SubstitutionContext()
        {
            ThreadContext = new ThreadLocalContext();
            var callSpecificationFactory = CallSpecificationFactoryFactoryYesThatsRight.CreateCallSpecFactory();

            _callRouterResolver = new CallRouterResolver();

            var sequenceNumberGenerator = new SequenceNumberGenerator();

#pragma warning disable 618 // Obsolete
            SequenceNumberGenerator = sequenceNumberGenerator;
#pragma warning restore 618 // Obsolete

            RouteFactory = new RouteFactory(sequenceNumberGenerator, ThreadContext, callSpecificationFactory);

            var callInfoFactory           = new CallInfoFactory();
            var autoValueProvidersFactory = new AutoValueProvidersFactory();
            var substituteStateFactory    = new SubstituteStateFactory(callSpecificationFactory, callInfoFactory, autoValueProvidersFactory);
            var callRouterFactory         = new CallRouterFactory(ThreadContext, RouteFactory);
            var argSpecificationQueue     = new ArgumentSpecificationDequeue(ThreadContext.DequeueAllArgumentSpecifications);
            var dynamicProxyFactory       = new CastleDynamicProxyFactory(argSpecificationQueue);
            var delegateFactory           = new DelegateProxyFactory(dynamicProxyFactory);
            var proxyFactory = new ProxyFactory(delegateFactory, dynamicProxyFactory);
            SubstituteFactory = new SubstituteFactory(substituteStateFactory, callRouterFactory, proxyFactory);
        }
Пример #8
0
        public static SubstituteState Create(ISubstitutionContext substitutionContext)
        {
            var substituteFactory        = substitutionContext.SubstituteFactory;
            var callInfoFactory          = new CallInfoFactory();
            var callStack                = new CallStack();
            var pendingSpecification     = new PendingSpecification();
            var callResults              = new CallResults(callInfoFactory);
            var callSpecificationFactory = NewCallSpecificationFactory();
            var callActions              = new CallActions(callInfoFactory);

            var callFormatter = new CallFormatter();

            var state = new object[]
            {
                callInfoFactory,
                callStack,
                pendingSpecification,
                callResults,
                callSpecificationFactory,
                substituteFactory,
                callActions,
                new PropertyHelper(),
                new ResultSetter(callStack, pendingSpecification, callResults, callSpecificationFactory, callActions),
                new EventHandlerRegistry(),
                new ReceivedCallsExceptionThrower(),
                new DefaultForType(),
                new IAutoValueProvider[] { new AutoSubstituteProvider(substituteFactory), new AutoStringProvider(), new AutoArrayProvider() }
            };

            return(new SubstituteState(state));
        }