예제 #1
0
        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);
        }
예제 #2
0
        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());
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }