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 SubscribedActionInvoked() { var mediatRCourier = new MediatRCourier(); var receivedMessage = false; void NotificationAction(TestNotification _, CancellationToken __) => receivedMessage = true; mediatRCourier.Subscribe <TestNotification>(NotificationAction); await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false); Assert.True(receivedMessage); }
public async Task SubscribedAsyncActionInvoked() { var mediatRCourier = new MediatRCourier(); var receivedMessage = false; async Task NotificationAction(TestNotification _, CancellationToken cancellationToken) { receivedMessage = true; await Task.Delay(TimeSpan.FromMilliseconds(1), cancellationToken).ConfigureAwait(false); } mediatRCourier.Subscribe <TestNotification>(NotificationAction); await mediatRCourier.Handle(new TestNotification(), CancellationToken.None).ConfigureAwait(false); Assert.True(receivedMessage); }