Esempio n. 1
0
        public BusTestScenario(TimeSpan timeout, IBusControl busControl)
        {
            _timeout    = timeout;
            _busControl = busControl;

            Received   = new ReceivedMessageList(timeout);
            _skipped   = new ReceivedMessageList(timeout);
            _published = new PublishedMessageList(timeout);

            _tokenSource      = new CancellationTokenSource(timeout);
            CancellationToken = _tokenSource.Token;


            var testSendObserver = new TestSendObserver(timeout);

            Sent = testSendObserver.Messages;

            _subjectSendEndpoint = GetSendEndpoint(testSendObserver);

            var consumeObserver = new TestConsumeObserver(timeout);

            Received = consumeObserver.Messages;
            busControl.ConnectConsumeObserver(consumeObserver);

            _busHandle = _busControl.Start();
        }
Esempio n. 2
0
            public async Task SetupObservers()
            {
                _pingObserver = GetConsumeObserver <PingMessage>();
                Bus.ConnectConsumeMessageObserver(_pingObserver);

                _observer = GetConsumeObserver();
                Bus.ConnectConsumeObserver(_observer);

                await Bus.Publish(new PingMessage());
            }
Esempio n. 3
0
            public void SetupObservers()
            {
                _pingObserver = GetConsumeObserver <PingMessage>();
                Bus.ConnectConsumeMessageObserver(_pingObserver);

                _observer = GetConsumeObserver();
                Bus.ConnectConsumeObserver(_observer);

                Await(() => Bus.Publish(new PingMessage()));
            }
            public void SetupObservers()
            {
                _pingObserver = GetConsumeObserver<PingMessage>();
                Bus.ConnectConsumeMessageObserver(_pingObserver);

                _observer = GetConsumeObserver();
                Bus.ConnectConsumeObserver(_observer);

                Await(() => Bus.Publish(new PingMessage()));
            }
            public async Task SetupObservers()
            {
                _pingObserver = GetConsumeObserver<PingMessage>();
                Bus.ConnectConsumeMessageObserver(_pingObserver);

                _observer = GetConsumeObserver();
                Bus.ConnectConsumeObserver(_observer);

                await Bus.Publish(new PingMessage());
            }
Esempio n. 6
0
        public void Should_invoke_faulted()
        {
            IConsumePipe filter = CreateConsumePipe();

            filter.ConnectHandler <MessageA>(async context =>
            {
                throw new IntentionalTestException("This is a test");
            });

            TestConsumeObserver <MessageA> interceptor = GetConsumeObserver <MessageA>();

            filter.ConnectConsumeMessageObserver(interceptor);

            ConsumeContext consumeContext = GetConsumeContext(new MessageA());

            Assert.Throws <IntentionalTestException>(async() => await filter.Send(consumeContext));

            Assert.Throws <IntentionalTestException>(async() => await interceptor.ConsumeFaulted);
        }
Esempio n. 7
0
        public async Task Should_invoke_pre()
        {
            IConsumePipe filter = CreateConsumePipe();

            TaskCompletionSource <MessageA> received = GetTask <MessageA>();

            filter.ConnectHandler <MessageA>(async context => received.TrySetResult(context.Message));

            TestConsumeObserver <MessageA> interceptor = GetConsumeObserver <MessageA>();

            filter.ConnectConsumeMessageObserver(interceptor);

            ConsumeContext consumeContext = GetConsumeContext(new MessageA());

            await filter.Send(consumeContext);

            await received.Task;

            await interceptor.PreConsumed;
        }
Esempio n. 8
0
        public async Task Should_invoke_post_consumer()
        {
            IConsumePipe filter = CreateConsumePipe();

            TaskCompletionSource <MessageA> received = GetTask <MessageA>();

            filter.ConnectConsumer(() => new OneMessageConsumer(received));

            TestConsumeObserver <MessageA> interceptor = GetConsumeObserver <MessageA>();

            filter.ConnectConsumeMessageObserver(interceptor);

            ConsumeContext consumeContext = GetConsumeContext(new MessageA());

            await filter.Send(consumeContext);

            await received.Task;

            await interceptor.PostConsumed;
        }
Esempio n. 9
0
        public BusTestScenario(TimeSpan timeout, IBusControl busControl)
        {
            _timeout = timeout;
            _busControl = busControl;

            Received = new ReceivedMessageList(timeout);
            _skipped = new ReceivedMessageList(timeout);
            _published = new PublishedMessageList(timeout);

            _tokenSource = new CancellationTokenSource(timeout);
            CancellationToken = _tokenSource.Token;


            var testSendObserver = new TestSendObserver(timeout);
            Sent = testSendObserver.Messages;

            _subjectSendEndpoint = GetSendEndpoint(testSendObserver);

            var consumeObserver = new TestConsumeObserver(timeout);
            Received = consumeObserver.Messages;
            busControl.ConnectConsumeObserver(consumeObserver);

            _busHandle = _busControl.StartAsync();
        }
Esempio n. 10
0
        public BusTestScenario(TimeSpan timeout, IBusControl busControl)
        {
            _timeout = timeout;
            _busControl = busControl;

            Received = new ReceivedMessageList(timeout);
            _skipped = new ReceivedMessageList(timeout);
            _published = new PublishedMessageList(timeout);

            _tokenSource = new CancellationTokenSource(timeout);
            CancellationToken = _tokenSource.Token;

            _subjectSendEndpoint = _busControl.GetSendEndpoint(new Uri("loopback://localhost/input_queue")).Result;

            var testSendObserver = new TestSendObserver(timeout);
            Sent = testSendObserver.Messages;
            _subjectSendEndpoint.ConnectSendObserver(testSendObserver);

            var consumeObserver = new TestConsumeObserver(timeout);
            Received = consumeObserver.Messages;
            busControl.ConnectConsumeObserver(consumeObserver);

            _busHandle = _busControl.Start();
        }