Ejemplo n.º 1
0
        public async Task Enable_then_Disable_should_subscribe_and_unsubscribe()
        {
            var bus     = new FakeBus();
            var pattern = new PatternBuilder("root").Build();

            using var subscription = new AsyncActionSubscription(bus, pattern, e => Task.CompletedTask);

            await subscription.EnableAsync().ConfigureAwait(false);

            Assert.True(bus.IsSubscribed(subscription));

            await subscription.DisableAsync().ConfigureAwait(false);

            Assert.False(bus.IsSubscribed(subscription));
        }
Ejemplo n.º 2
0
        public async Task Enable_then_Disable_multiple_times_should_set_isEnabled_accordingly(int times)
        {
            var bus     = new FakeBus();
            var pattern = new PatternBuilder("root").Build();

            using var subscription = new AsyncActionSubscription(bus, pattern, e => Task.CompletedTask);

            for (int i = 0; i < times; i++)
            {
                await subscription.EnableAsync().ConfigureAwait(false);

                Assert.True(subscription.IsEnabled);

                await subscription.DisableAsync().ConfigureAwait(false);

                Assert.False(subscription.IsEnabled);
            }
        }