public async Task MultipleSubscribedAsyncMethodsInvoked()
        {
            var mediatRCourier = new MediatRCourier();

            var testClient = new TestInterfaceClientWithTwoAsyncMethods(mediatRCourier);

            await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false);

            await mediatRCourier.Handle(new TestNotification2(), CancellationToken.None).ConfigureAwait(false);

            Assert.True(testClient.MessageReceived);
            Assert.True(testClient.MessageReceived2);
        }
        public async Task AsyncVoidActionMightCompleteInTime(TimeSpan delayTime)
        {
            var mediatRCourier = new MediatRCourier();

            var receivedMessage = false;

            async void NotificationAction(TestNotification _, CancellationToken cancellationToken)
            {
                await Task.Delay(delayTime, cancellationToken).ConfigureAwait(false);

                receivedMessage = true;
            }

            mediatRCourier.Subscribe <TestNotification>(NotificationAction);

            await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false);

            if (delayTime.Ticks == 0)
            {
                Assert.True(receivedMessage);
            }
            else
            {
                Assert.False(receivedMessage);
            }
        }
        public async Task UnSubscribedActionNotInvoked()
        {
            var mediatRCourier = new MediatRCourier();

            var receivedMessageCount = 0;

            void NotificationAction(TestNotification _, CancellationToken __) => ++ receivedMessageCount;

            mediatRCourier.Subscribe <TestNotification>(NotificationAction);

            await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false);

            mediatRCourier.UnSubscribe <TestNotification>(NotificationAction);

            await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false);

            Assert.True(receivedMessageCount == 1);
        }
        public async Task UnSubscribedMethodNotInvoked()
        {
            var mediatRCourier = new MediatRCourier();

            var testClient = new TestInterfaceClient1Cancellation(mediatRCourier);

            testClient.Dispose();

            await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false);

            Assert.False(testClient.MessageReceived);
        }
        public async Task UnSubscribedAsyncActionNotInvoked()
        {
            var mediatRCourier = new MediatRCourier();

            var receivedMessageCount = 0;

            async Task NotificationAction(TestNotification _, CancellationToken cancellationToken)
            {
                ++receivedMessageCount;

                await Task.Delay(TimeSpan.FromMilliseconds(1), cancellationToken).ConfigureAwait(false);
            }

            mediatRCourier.Subscribe <TestNotification>(NotificationAction);

            await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false);

            mediatRCourier.UnSubscribe <TestNotification>(NotificationAction);

            await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false);

            Assert.True(receivedMessageCount == 1);
        }