public void GetSnapshot_ExistingIdWithPastSnapshot_OnlyRelevantEventsApplied() { var eventStore = _dbContext.Persons.Add(new PersonEventStore { Id = 12 }).Entity; eventStore.Events.Add(new PersonEvent { SerializedEvent = "{" + "\"$type\": \"Silverback.Tests.EventSourcing.EntityFrameworkCore.TestTypes.Person+NameChangedEvent, Silverback.EventSourcing.EntityFrameworkCore.Tests\"," + "\"NewName\": \"Silverback\"" + "}", Timestamp = DateTime.Parse("2000-05-05") }); eventStore.Events.Add(new PersonEvent { SerializedEvent = "{" + "\"$type\": \"Silverback.Tests.EventSourcing.EntityFrameworkCore.TestTypes.Person+NameChangedEvent, Silverback.EventSourcing.EntityFrameworkCore.Tests\"," + "\"NewName\": \"Sergio\"" + "}", Timestamp = DateTime.Parse("2000-03-01") }); eventStore.Events.Add(new PersonEvent { SerializedEvent = "{" + "\"$type\": \"Silverback.Tests.EventSourcing.EntityFrameworkCore.TestTypes.Person+AgeChangedEvent, Silverback.EventSourcing.EntityFrameworkCore.Tests\"," + "\"NewAge\": 16" + "}", Timestamp = DateTime.Parse("2000-02-01") }); eventStore.Events.Add(new PersonEvent { SerializedEvent = "{" + "\"$type\": \"Silverback.Tests.EventSourcing.EntityFrameworkCore.TestTypes.Person+AgeChangedEvent, Silverback.EventSourcing.EntityFrameworkCore.Tests\"," + "\"NewAge\": 35" + "}", Timestamp = DateTime.Parse("2019-07-06") }); _dbContext.SaveChanges(); var repo = new PersonEventStoreRepository(_dbContext); var entity = repo.GetSnapshot(p => p.Id == 12, DateTime.Parse("2000-03-01")); entity.Name.Should().Be("Sergio"); entity.Age.Should().Be(16); }