public void Can_handle_events_published_after_action_but_before_awaiting() { var canPublishEvent = new AutoResetEvent(false); var canAwaitEvent = new AutoResetEvent(false); var source = new EventJournalSource(); var journal = new EventJournal(source); string handledMessage = string.Empty; var task = Task.Run(() => { canPublishEvent.Set(); canAwaitEvent.AssertWaitOneSuccess(); journal.When <SpeechRequestedEvent>(ev => handledMessage = ev.Message) .WaitAny(TimeSpan.FromMilliseconds(100)); }); source.NotifyAction(); canPublishEvent.AssertWaitOneSuccess(); source.Publish(new SpeechRequestedEvent("message1")); canAwaitEvent.Set(); journal.AwaitingStarted.AssertWaitOneSuccess(); source.Publish(new SpeechRequestedEvent("message2 - we don't want to get this one")); task.AssertWaitFastSuccess(); handledMessage.Should().Be("message1"); }
public void NotifyAction() => source.NotifyAction();