コード例 #1
0
        public void ExecuteNextStep_ExecutingWhileTriggeringNewSequenceOfEventsAsync_CanHandleAsyncExecuteAndAddNewSequences()
        {
            // Arrange
            var sequence = new TriggeredMessageSequence();

            var executionContext = new SequenceExecutionContext(new List <IMessageSequence> {
                sequence
            }, "whatever", new Mock <IMessagePicker>().Object);

            sequence.SetNextStep(new SendMessage(new Mock <ISender>().Object));

            // Act
            IList <Task> tasks = new List <Task>();

            for (int i = 0; i < 1000; i++)
            {
                var execute = new Task(obj => sequence.ExecuteNextStep(obj as SequenceExecutionContext), executionContext);
                var triggerNewSequenceOfEvents = new Task(() => sequence.TriggerNewSequenceOfEvents(new Mock <IMessageInitializerParameterBinder>().Object));

                tasks.Add(execute);
                tasks.Add(triggerNewSequenceOfEvents);

                execute.Start();
                triggerNewSequenceOfEvents.Start();
            }

            foreach (var task in tasks)
            {
                task.Wait();
            }

            // Assert
            Assert.That(tasks.All(task => task.IsCompleted));
        }
コード例 #2
0
        public void ExecuteNextStep_ExecutingWhileTriggeringNewSequenceOfEventsAsync_CanHandleAsyncExecuteAndAddNewSequences()
        {
            // Arrange
            var sequence = new TriggeredMessageSequence();

            var executionContext = new SequenceExecutionContext(new List<IMessageSequence> {sequence}, "whatever", new Mock<IMessagePicker>().Object);

            sequence.SetNextStep(new SendMessage(new Mock<ISender>().Object));

            // Act
            IList<Task> tasks = new List<Task>();

            for (int i = 0; i < 1000; i++)
            {
                var execute = new Task(obj => sequence.ExecuteNextStep(obj as SequenceExecutionContext), executionContext);
                var triggerNewSequenceOfEvents = new Task(() => sequence.TriggerNewSequenceOfEvents(new Mock<IMessageInitializerParameterBinder>().Object));

                tasks.Add(execute);
                tasks.Add(triggerNewSequenceOfEvents);

                execute.Start();
                triggerNewSequenceOfEvents.Start();
            }

            foreach (var task in tasks)
            {
                task.Wait();
            }

            // Assert
            Assert.That(tasks.All(task => task.IsCompleted));
        }
コード例 #3
0
        private SendAfterEndpointEventConfiguration CallsInternal(VoidDelegate voidDelegate)
        {
            var sequence = new TriggeredMessageSequence();
            var trigger  = new InvocationTriggeringSequenceOfEvents(_invocationMatcher, sequence);

            _wcfProxy.AddInvocation(trigger, voidDelegate);

            return(new SendAfterEndpointEventConfiguration(sequence, _service));
        }
コード例 #4
0
        private SendAfterEndpointEventConfiguration ReturnsInternal(IInvocationReturnValueProducer returnValueProducer)
        {
            var sequence = new TriggeredMessageSequence();
            var trigger  = new InvocationTriggeringSequenceOfEvents(_invocationMatcher, sequence);

            _wcfProxy.AddInvocation(trigger, returnValueProducer);

            return(new SendAfterEndpointEventConfiguration(sequence, _service));
        }
コード例 #5
0
        public SendAfterEndpointEventConfiguration Returns <T1, T2, T3, T4, T5, T6, T7, T8>(Func <T1, T2, T3, T4, T5, T6, T7, T8, R> returnValueProducer)
        {
            var sequence  = new TriggeredMessageSequence();
            var inspector = new RouteInvocationTriggeringSequenceOfEvents(_route, _matcher, sequence);

            _route.AddReturn(inspector, new ProduceDelegateReturnValue(returnValueProducer, new MapRequestToDelegateHeuristic(_route.Route, returnValueProducer)));

            return(new SendAfterEndpointEventConfiguration(sequence, _service));
        }
コード例 #6
0
        public SendAfterEndpointEventConfiguration Returns(R returnValue)
        {
            var sequence  = new TriggeredMessageSequence();
            var inspector = new RouteInvocationTriggeringSequenceOfEvents(_route, _matcher, sequence);

            _route.AddReturn(inspector, new ProduceStaticReturnValue(returnValue));

            return(new SendAfterEndpointEventConfiguration(sequence, _service));
        }
コード例 #7
0
        public ReturnFromPostInvocationConfiguration With(IPostInvocationConfiguration configuration)
        {
            var sequence = new TriggeredMessageSequence();
            var inspector = new RouteInvocationTriggeringSequenceOfEvents(_route, configuration.CreateInvocationInspector(_route), sequence);

            var returnValueProxy = new NullOrInvocationReturnValueProducer();
            _route.AddReturn(inspector, returnValueProxy);

            return new ReturnFromPostInvocationConfiguration(sequence, _service, returnValueProxy);
        }
コード例 #8
0
        public SendAfterEndpointEventConfiguration Setup(Expression <Action <T> > methodSignatureExpectation)
        {
            IInvocationMatcher invocationMatcher = _parser.Parse(methodSignatureExpectation);

            var sequence = new TriggeredMessageSequence();
            var trigger  = new InvocationTriggeringSequenceOfEvents(invocationMatcher, sequence);

            _serviceImplementation.AddInvocation(trigger, new ProduceNullReturnValue());

            return(new SendAfterEndpointEventConfiguration(sequence, _service));
        }
コード例 #9
0
        public ReturnFromPostInvocationConfiguration With(IPostInvocationConfiguration configuration)
        {
            var sequence  = new TriggeredMessageSequence();
            var inspector = new RouteInvocationTriggeringSequenceOfEvents(_route, configuration.CreateInvocationInspector(_route), sequence);

            var returnValueProxy = new NullOrInvocationReturnValueProducer();

            _route.AddReturn(inspector, returnValueProxy);

            return(new ReturnFromPostInvocationConfiguration(sequence, _service, returnValueProxy));
        }
コード例 #10
0
 public InvocationTriggeringSequenceOfEvents(IInvocationMatcher matcher, TriggeredMessageSequence sequence)
 {
     _matcher = matcher;
     _sequence = sequence;
 }
コード例 #11
0
 public RouteInvocationTriggeringSequenceOfEvents(IRouteTemplate routeOwningUrl, IInvocationMatcher matcher, TriggeredMessageSequence sequence)
 {
     _routeOwningUrl = routeOwningUrl;
     _matcher = matcher;
     _sequence = sequence;
 }
コード例 #12
0
 public RouteInvocationTriggeringSequenceOfEvents(IRouteTemplate routeOwningUrl, IInvocationMatcher matcher, TriggeredMessageSequence sequence)
 {
     _routeOwningUrl = routeOwningUrl;
     _matcher        = matcher;
     _sequence       = sequence;
 }
コード例 #13
0
 public ReturnFromPostInvocationConfiguration(TriggeredMessageSequence sequenceBeingConfigured, ServiceStub componentBeingConfigured, NullOrInvocationReturnValueProducer returnValueProxy) : base(sequenceBeingConfigured, componentBeingConfigured)
 {
     _sequenceBeingConfigured  = sequenceBeingConfigured;
     _componentBeingConfigured = componentBeingConfigured;
     _returnValueProxy         = returnValueProxy;
 }
コード例 #14
0
 public InvocationTriggeringSequenceOfEvents(IInvocationMatcher matcher, TriggeredMessageSequence sequence)
 {
     _matcher  = matcher;
     _sequence = sequence;
 }