Beispiel #1
0
        public async Task SubscribeByCategoryAsync()
        {
            var store = new InMemoryEventStore();
            await store.SubscribeByCategory("game", CancellationToken.None, ed => store.AppendToStreamAsync("projection-ongoing-games", new[] { ed.Event }));

            var e1 = new GameStarted {
                GameId = Guid.NewGuid(), PlayerId = "*****@*****.**"
            };
            await store.AppendToStreamAsync($"game-{e1.GameId}", new[] { e1 });

            var e2 = new GameStarted {
                GameId = Guid.NewGuid(), PlayerId = "*****@*****.**"
            };
            await store.AppendToStreamAsync($"game-{e2.GameId}", new[] { e2 });

            await Task.Delay(600);

            var r = await store.LoadEventStreamAsync("projection-ongoing-games", 0);

            Assert.Equal(2, r.Events.Count());
        }