Пример #1
0
        public void Should_invoke_all_registered_handlers()
        {
            var bus = new Bus(new FakeBusConfig(), new NullLogger(), new FakeValidMessageQueue(), QueueWithOneMessage(), new[] { new FakeValidMessageQueue() });
            var handler = new FakeEndUserHandler();
            bus.RegisterHandler(handler);
            bus.RegisterHandler(handler);
            bus.RegisterHandler(handler);

            bus.Receive<FakeDto>();

            Assert.That(handler.InvokeCount, Is.EqualTo(3));
        }
Пример #2
0
        public void Should_log_all_steps_involved()
        {
            var logger = new FakeLogger();
            var handler = new FakeEndUserHandler();
            var bus = new Bus(new FakeBusConfig(), logger, new FakeValidMessageQueue(), QueueWithOneMessage(), new[] { new FakeValidMessageQueue() });
            bus.RegisterHandler(handler);

            bus.Receive<FakeDto>();

            Assert.That(logger[0], Is.StringEnding("Transaction started"));
            Assert.That(logger[1], Is.StringEnding("Started RECEIVE Operation"));
            Assert.That(logger[2], Is.StringEnding("Payload: FakeDto"));
            Assert.That(logger[3], Is.StringEnding("Invoking registered handler"));
            Assert.That(logger[4], Is.StringEnding("Removing from read queue: FakeValidMessageQueue"));
            Assert.That(logger[5], Is.StringEnding("Completed RECEIVE Operation"));
            Assert.That(logger[6], Is.StringEnding("Transaction committed"));
        }