コード例 #1
0
        public async Task Aggregates_Multiple_Streams_In_Order()
        {
            var store = new FileSystemEventStore(EventPath);

            DeleteEvents();

            var eventsReceived = new List <IEvent>();

            store.EventHandler = e =>
            {
                eventsReceived.Add(e);
                return(Task.CompletedTask);
            };

            // Raise some events
            await store.RaiseEventAsync(new TestEvent("Hello, World!"));

            await store.RaiseEventAsync(new AnotherTestEvent("Hello, Bob!"));

            await store.RaiseEventAsync(new TestEvent("Hello, Dave!"));

            // Pretend we haven't seen them yet
            eventsReceived.Clear();

            // Replay and check they are correct
            await store.ReplayAllEvents();

            eventsReceived[0].Stream.ShouldBe("test-stream");
            ((TestEvent)eventsReceived[0]).TestValue.ShouldBe("Hello, World!");
            eventsReceived[1].Stream.ShouldBe("another-test-stream");
            ((AnotherTestEvent)eventsReceived[1]).TestValue.ShouldBe("Hello, Bob!");
            eventsReceived[2].Stream.ShouldBe("test-stream");
            ((TestEvent)eventsReceived[2]).TestValue.ShouldBe("Hello, Dave!");
        }
コード例 #2
0
        public async Task Does_Not_Throw_Replaying_No_Events()
        {
            var store = new FileSystemEventStore(EventPath);

            DeleteEvents();
            await store.ReplayAllEvents();
        }