Пример #1
0
        public async Task when_disposed_it_should_not_be_possible_to_start_router()
        {
            var            state = new TestDriverState();
            IMessageRouter messageRouter;

            await using (var container = RoutingTests.SetupContainer(_testOutputHelper)
                                         .AddRouterWithThreeBrokers(
                             RoutingTests.RandomString(),
                             RoutingTests.RandomString(),
                             RoutingTests.RandomString(),
                             state))
            {
                messageRouter = container.GetMessageRouter();
            }

            Func <Task> sut = () => messageRouter.Start();

            sut.Should().ThrowExactly <PoezdOperationException>().Where(
                exception => exception.Message.Contains("disposed", StringComparison.InvariantCultureIgnoreCase),
                "it's not possible to start disposed message router");
        }
Пример #2
0
        public async Task when_used_it_should_live_expected_life()
        {
            var state = new TestDriverState();

            await using (var container = RoutingTests.SetupContainer(_testOutputHelper)
                                         .AddRouterWithThreeBrokers(
                             RoutingTests.RandomString(),
                             RoutingTests.RandomString(),
                             RoutingTests.RandomString(),
                             state))
            {
                var messageRouter = container.GetMessageRouter();
                state.InitializedCount.Should().Be(expected: 0, "all 6 drivers should not be initialized");
                state.MessageConsumingStartedCount.Should().Be(expected: 0, "among 6 drivers none should start message consuming at this moment");
                await messageRouter.Start();

                state.MessageConsumingStartedCount.Should().Be(expected: 3, "among 6 drivers 3 ingress drivers should be started");
                state.DisposedCount.Should().Be(expected: 0, "among 6 drivers none should be disposed at this moment");
            }

            state.DisposedCount.Should().Be(expected: 6, "all 6 drivers should be disposed at this moment");
        }