Beispiel #1
0
        public void Can_await_one_event()
        {
            var             source        = new EventJournalSource();
            var             journal       = new EventJournal(source);
            var             executedEvent = new AutoResetEvent(false);
            QuestArrowEvent receivedEvent = null;

            var x    = journal.AwaitingStarted;
            var task = Task.Run(() =>
            {
                journal.When <QuestArrowEvent>(e =>
                {
                    receivedEvent = e;
                    executedEvent.Set();
                })
                .WaitAny();
            });

            journal.AwaitingStarted.AssertWaitOneSuccess();

            source.Publish(new QuestArrowEvent(true, new Location2D(123, 321)));

            executedEvent.AssertWaitOneSuccess();

            receivedEvent.Should().NotBeNull();
            receivedEvent.Active.Should().BeTrue();
            receivedEvent.Location.Should().Be(new Location2D(123, 321));
        }