protected override async Task When()
        {
            MethodCallCounter.Clear();

            var command1 = new FooCommand(_id1);
            var command2 = new FooCommand(_id2);

            await Subject.Dispatch(await _brokeredMessageFactory.Create(command1));

            await Subject.Dispatch(await _brokeredMessageFactory.Create(command2));

            MethodCallCounter.Stop();
        }
Esempio n. 2
0
        public void TheExceptionIsBubbledBackThroughTheInterceptors()
        {
            var interceptor = Substitute.For <IInboundInterceptor>();

            interceptor
            .When(x => x.OnCommandHandlerExecuting(Arg.Any <EmptyCommand>(), Arg.Any <BrokeredMessage>()))
            .Do(x =>
            {
                throw new Exception("Ruh roh");
            });
            var dispatcher      = GetCommandMessageDispatcher <EmptyCommand, EmptyCommandHandler>(interceptor);
            var brokeredMessage = BrokeredMessageFactory.Create(new EmptyCommand()).Result;

            try
            {
                dispatcher.Dispatch(brokeredMessage).Wait();
            }
            catch (AggregateException)
            {
                // Dispatch rethrows the exception, don't care
            }

            interceptor
            .Received()
            .OnCommandHandlerError(Arg.Any <EmptyCommand>(), brokeredMessage, Arg.Any <Exception>());
        }
        public void TheExceptionIsBubbledThroughTheInterceptors()
        {
            var interceptor     = Substitute.For <IInboundInterceptor>();
            var dispatcher      = GetRequestMessageDispatcher <ExceptingRequest, ExceptingResponse, ExceptingRequestHandler>(interceptor);
            var brokeredMessage = BrokeredMessageFactory.Create(new ExceptingRequest()).Result;

            dispatcher.Dispatch(brokeredMessage).Wait();

            interceptor
            .Received()
            .OnRequestHandlerError(Arg.Any <ExceptingRequest>(), brokeredMessage, Arg.Any <Exception>());
        }
Esempio n. 4
0
        public void TheExceptionIsBubbledBackThroughTheInterceptors()
        {
            var interceptor = Substitute.For <IInboundInterceptor>();

            interceptor
            .When(x => x.OnRequestHandlerExecuting(Arg.Any <EmptyRequest>(), Arg.Any <BrokeredMessage>()))
            .Do(x => { throw new Exception("Ruh roh"); });
            var dispatcher      = GetRequestMessageDispatcher <EmptyRequest, EmptyResponse, EmptyRequestHandler>(interceptor);
            var brokeredMessage = BrokeredMessageFactory.Create(new EmptyRequest()).Result;

            dispatcher.Dispatch(brokeredMessage).Wait();

            interceptor
            .Received()
            .OnRequestHandlerError(Arg.Any <EmptyRequest>(), brokeredMessage, Arg.Any <Exception>());
        }
        public void TheExceptionIsBubbledThroughTheInterceptors()
        {
            var interceptor     = Substitute.For <IInboundInterceptor>();
            var dispatcher      = GetEventMessageDispatcher <ExceptingEvent, ExceptingEventHandler>(interceptor);
            var brokeredMessage = BrokeredMessageFactory.Create(new ExceptingEvent()).Result;

            try
            {
                dispatcher.Dispatch(brokeredMessage).Wait();
            }
            catch (AggregateException)
            {
                // Dispatch rethrows the exception, don't care
            }

            interceptor
            .Received()
            .OnEventHandlerError(Arg.Any <ExceptingEvent>(), brokeredMessage, Arg.Any <Exception>());
        }
        private async Task <BrokeredMessage> When(BrokeredMessageFactory brokeredMessageFactory)
        {
            var bigFatObject = new string(Enumerable.Range(0, 256 * 1024).Select(i => '.').ToArray());

            return(await brokeredMessageFactory.Create(bigFatObject));
        }