public void GivenAggregateWithMultipleEvents_WhenLoadingSpecificVersion_ThenShouldOnlyReturnRequestedEvents(int version) { // Arrange IEventStore store = new SqlServerEventStoreTestDataBuilder().Build(); var customerId = Guid.NewGuid(); var storedEvents = new EventChain().Add(new CustomerSignedUp(customerId)) .Add(new SubscribedToNewsletter("latest")) .Add(new SubscribedToNewsletter("top")); store.Save <Customer>(customerId.ToString(), EventStreamVersion.NoStream, storedEvents); // Act var stream = store.Load <Customer>(customerId.ToString(), version); // Assert CollectionAssert.AreEqual(storedEvents.Take(version + 1), stream.Events, "Events loaded from store do not match version requested."); }
public void GivenAggregateWithMultipleEvents_WhenLoadingSpecificVersion_ThenShouldOnlyReturnRequestedEvents() { // Arrange IEventStore store = new DelayedWriteRavenEventStore(_documentStore); var customerId = Guid.NewGuid(); var storedEvents = new EventChain().Add(new CustomerSignedUp(customerId)) .Add(new SubscribedToNewsletter("latest")) .Add(new SubscribedToNewsletter("top")); store.Save <Customer>(customerId.ToString(), 0, storedEvents); // Act var stream = store.Load <Customer>(customerId.ToString(), storedEvents[1].Version); // Assert CollectionAssert.AreEqual(storedEvents.Take(2), stream.Events, "Events loaded from store do not match version requested."); }
public void GivenEventStorePopulatedWithManyEventsForAnAggregate_WhenLoadingForSpecificVersion_ThenShouldOnlyLoadEventsUpToAndIncludingThatVersion() { // Arrange IEventStore store = new InMemoryEventStore(new ConsoleLogger()); var id = Guid.NewGuid(); var allEvents = new EventChain().Add(new UserRegistered(id)) .Add(new UserChangedPassword("pwd1")) .Add(new UserChangedPassword("pwd2")) .Add(new UserChangedPassword("pwd3")) .Add(new UserChangedPassword("pwd4")); store.Save <User>(id.ToString(), 0, allEvents); // Act IEnumerable <IEvent> version3 = store.Load <User>(id.ToString(), allEvents[2].Version).Events; // Assert CollectionAssert.AreEqual(allEvents.Take(3).ToArray(), version3); }