public async Task ValidateSuccessfulErrorFlowDoesNotThrowErrors() { var provider = services.BuildServiceProvider(); var outChannel = new DirectChannel(provider); var handler = new ExceptionHandler(); outChannel.Subscribe(handler); var errorChannel = new PublishSubscribeChannel(provider); var errorService = new SuccessfulErrorService(); var errorHandler = new ServiceActivatingHandler(provider, errorService); errorChannel.Subscribe(errorHandler); var mps = new TestMessageProducerSupportEndpoint(provider); mps.OutputChannel = outChannel; mps.ErrorChannel = errorChannel; await mps.Start(); var message = new GenericMessage("hello"); mps.SendMessage(message); Assert.IsType <ErrorMessage>(errorService.LastMessage); Assert.IsType <MessageDeliveryException>(errorService.LastMessage.Payload); var exception = (MessageDeliveryException)errorService.LastMessage.Payload; Assert.Equal(message, exception.FailedMessage); }
public async Task TestWithChannelName() { services.AddSingleton <IMessageChannel>((p) => new DirectChannel(p, "foo")); var provider = services.BuildServiceProvider(); var mps = new TestMessageProducerSupportEndpoint(provider); mps.OutputChannelName = "foo"; await mps.Start(); Assert.NotNull(mps.OutputChannel); Assert.Equal("foo", mps.OutputChannel.Name); }
public async Task ValidateExceptionIfNoErrorChannel() { var provider = services.BuildServiceProvider(); var outChannel = new DirectChannel(provider); var handler = new ExceptionHandler(); outChannel.Subscribe(handler); var mps = new TestMessageProducerSupportEndpoint(provider); mps.OutputChannel = outChannel; await mps.Start(); Assert.Throws <MessageDeliveryException>(() => mps.SendMessage(new GenericMessage("hello"))); }
public async Task ValidateExceptionIfSendToErrorChannelFails() { var provider = services.BuildServiceProvider(); var outChannel = new DirectChannel(provider.GetService <IApplicationContext>()); var handler = new ExceptionHandler(); outChannel.Subscribe(handler); var errorChannel = new PublishSubscribeChannel(provider.GetService <IApplicationContext>()); errorChannel.Subscribe(handler); var mps = new TestMessageProducerSupportEndpoint(provider.GetService <IApplicationContext>()); mps.OutputChannel = outChannel; mps.ErrorChannel = errorChannel; await mps.Start(); Assert.Throws <MessageDeliveryException>(() => mps.SendMessage(Message.Create("hello"))); }