public void PreSendInterceptorReturningModifiedMessage()
        {
            var expected    = new Mock <IMessage>().Object;
            var interceptor = new PreSendInterceptor
            {
                MessageToReturn = expected
            };

            channel.AddInterceptor(interceptor);
            channel.Send(MessageBuilder.WithPayload("test").Build());

            Assert.Single(messageHandler.Messages);
            var result = messageHandler.Messages[0];

            Assert.NotNull(result);
            Assert.Same(expected, result);
            Assert.True(interceptor.WasAfterCompletionInvoked);
        }
Example #2
0
    public void TaskSchedulerSubscribableChannel_Send_10_000_000()
    {
        var channel = new TaskSchedulerSubscribableChannel();
        var handler = new CounterHandler();

        channel.Subscribe(handler);
        var message = Message.Create("test");

        for (var i = 0; i < 10_000_000; i++)
        {
            channel.Send(message);
        }
    }
Example #3
0
    public void TaskSchedulerSubscribableChannel_Send_10_000_000()
    {
        var channel = new TaskSchedulerSubscribableChannel();
        var handler = new CounterHandler();

        channel.Subscribe(handler);
        GenericMessage message = new GenericMessage("test");

        for (int i = 0; i < 10_000_000; i++)
        {
            channel.Send(message);
        }
    }
        public void SendWithScheduler()
        {
            var mock = new Mock <IMessageHandler>();

            _handler = mock.Object;
            var interceptor = new BeforeHandleInterceptor();
            var scheduler   = new TestScheduler();
            var testChannel = new TaskSchedulerSubscribableChannel(scheduler);

            testChannel.AddInterceptor(interceptor);
            testChannel.Subscribe(_handler);
            testChannel.Send(_message);
            Assert.True(scheduler.WasTaskScheduled);
            mock.Verify(h => h.HandleMessage(_message));
            Assert.Equal(1, interceptor.Counter);
            Assert.True(interceptor.WasAfterHandledInvoked);
        }