public void Remove_ExistingEntity_EntityDeleted() { var eventStore = new PersonEventStore { PersonId = 12 }; eventStore.Events.Add(new PersonEventStore.PersonEvent { SerializedEvent = "{" + "\"$type\": \"Silverback.Tests.EventSourcing.TestTypes.Person+NameChangedEvent, Silverback.EventSourcing.Tests\"," + "\"NewName\": \"Silverback\"" + "}" }); var repo = new PersonEventStoreRepository(eventStore); var entity = repo.GetById(12); entity.Should().NotBeNull(); repo.Remove(entity); repo.EventStores.Count.Should().Be(0); repo.EventStores.SelectMany(s => s.Events).Count().Should().Be(0); }
public void Remove_ExistingEntity_EntityDeleted() { 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\"" + "}" }); _dbContext.SaveChanges(); var repo = new PersonEventStoreRepository(_dbContext); var entity = repo.Get(p => p.Id == 12); entity.Should().NotBeNull(); repo.Remove(entity); _dbContext.SaveChanges(); _dbContext.Persons.Count().Should().Be(0); _dbContext.Persons.SelectMany(s => s.Events).Count().Should().Be(0); }
public void Remove_NonExistingEntity_ReturnsNull() { var repo = new PersonEventStoreRepository(); var entity = new Person(123); var result = repo.Remove(entity); result.Should().BeNull(); }