public async Task GetAllEventsByAggregateType_Should_Returns_AllConcernedEvents() { try { DeleteAll(); var store = new MongoDbEventStore(); List <IDomainEvent> events = new List <IDomainEvent>(); for (int i = 0; i < 100; i++) { if (i % 2 == 0) { events.Add(new EventAggA(Guid.NewGuid())); } else { events.Add(new EventAggB(Guid.NewGuid())); } } await store.StoreDomainEventRangeAsync(events); var store2 = new MongoDbEventStore(); (await store2.GetAllEventsByAggregateType(typeof(AggA)).ToListAsync()).Should().HaveCount(50); (await store2.GetAllEventsByAggregateType(typeof(AggB)).ToListAsync()).Should().HaveCount(50); } finally { DeleteAll(); } }
public async Task GetAllEventsByEventType_Generic_Should_Returns_OnlyConcernedEvents() { try { DeleteAll(); var store = new MongoDbEventStore(); List <IDomainEvent> events = new List <IDomainEvent>(); for (int i = 0; i < 100; i++) { if (i % 10 == 0) { events.Add(new EventAggA(Guid.NewGuid())); } else { events.Add(new EventAggB(Guid.NewGuid())); } } await store.StoreDomainEventRangeAsync(events); var store2 = new MongoDbEventStore(); (await store2.GetAllEventsByEventType <EventAggA>().ToListAsync()).Should().HaveCount(10); (await store2.GetAllEventsByEventType <EventAggB>().ToListAsync()).Should().HaveCount(90); } finally { DeleteAll(); } }
public async Task StoreDomainEventRangeAsync_Should_Store_AllEvents_ToDb() { try { DeleteAll(); Guid aggId = Guid.NewGuid(); var store = new MongoDbEventStore(); List <IDomainEvent> events = new List <IDomainEvent>(); for (int i = 0; i < 100; i++) { events.Add(new SampleEvent(aggId, Guid.NewGuid(), DateTime.Today) { Data = "testData" + i }); } await store.StoreDomainEventRangeAsync(events); (await GetEventCollection().CountDocumentsAsync(FilterDefinition <IDomainEvent> .Empty)).Should().Be(100); } finally { DeleteAll(); } }