public void WhenEntityDeleted_ThenPersists() { DatabaseTestUtility.DropCreateFirebrickDatabase(); // Arrange var repository = new DomainRepository(new DatabaseFactory()); Domain entity = DefaultModelHelper.DummyPopulatedDomain(); // Act repository.Add(entity); repository.Commit(); IEnumerable<Domain> returnedEntities = repository.GetAll(); // Assert Assert.Equal(1, returnedEntities.Count()); // Act repository.Delete(entity); repository.Commit(); // Arrange // Use a new context and repository to verify the vehicle was deleted var repositoryTwo = new DomainRepository(new DatabaseFactory()); IEnumerable<Domain> verifyEntities = repositoryTwo.GetAll(); // Assert Assert.NotNull(verifyEntities); Assert.Equal(0, verifyEntities.Count()); }
public void WhenAddingEntity_ThenGetAndUpdate() { DatabaseTestUtility.DropCreateFirebrickDatabase(); // Arrange var repository = new DomainRepository(new DatabaseFactory()); Domain newEntity = DefaultModelHelper.DummyPopulatedDomain(); // Act repository.Add(newEntity); repository.Commit(); // Use a new context and repository to verify the vehicle was added var repositoryTwo = new DomainRepository(new DatabaseFactory()); Domain loadedEntity = repositoryTwo.GetById(1); loadedEntity.HostHeader = "NewHostHeader"; repositoryTwo.Update(loadedEntity); repositoryTwo.Commit(); // Use a new context and repository to verify the vehicle was added var repositoryThree = new DomainRepository(new DatabaseFactory()); newEntity = repositoryThree.GetById(1); Assert.NotNull(newEntity); Assert.Equal("NewHostHeader", newEntity.HostHeader); }