public void Delete_WithExistingId_ShouldReturnTrue() { // Arrange StarStuffDbContext db = this.Database; PlanetService planetService = new PlanetService(db); this.SeedDatabase(db); // Act bool result = planetService.Delete(1); // Assert Assert.True(result); }
public void Delete_WithNotExistingId_ShouldNotRemovePlanet() { // Arrange StarStuffDbContext db = this.Database; PlanetService planetService = new PlanetService(db); int planetsCount = this.GetFakePlanets().Count; this.SeedDatabase(db); // Act planetService.Delete(11); // Assert Assert.Equal(planetsCount, db.Planets.Count()); }
public void Delete_WithNotExistingId_ShouldReturnFalse() { // Arrange StarStuffDbContext db = this.Database; PlanetService planetService = new PlanetService(db); int planetsCount = this.GetFakePlanets().Count; this.SeedDatabase(db); // Act bool result = planetService.Delete(planetsCount + 1); // Assert Assert.False(result); }
public void Delete_WithExistingId_ShouldRemovePlanet() { // Arrange StarStuffDbContext db = this.Database; PlanetService planetService = new PlanetService(db); int planetsCount = this.GetFakePlanets().Count; const int planetId = 1; this.SeedDatabase(db); // Act planetService.Delete(planetId); Planet planet = db.Planets.Find(planetId); // Assert Assert.Null(planet); Assert.Equal(planetsCount - 1, db.Planets.Count()); }