Beispiel #1
0
        public void Edit_WithNotExistingId_ShouldReturnFalse()
        {
            // Arrange
            StarStuffDbContext db            = this.Database;
            PlanetService      planetService = new PlanetService(db);

            this.SeedDatabase(db);

            // Act
            bool result = planetService.Edit(11, "Not Existing 1", 20.5);

            // Assert
            Assert.False(result);
        }
Beispiel #2
0
        public void Edit_WithDifferentExistingName_ShouldReturnFalse()
        {
            // Arrange
            StarStuffDbContext db            = this.Database;
            PlanetService      planetService = new PlanetService(db);

            this.SeedDatabase(db);

            Planet planet = this.GetFakePlanets().FirstOrDefault(p => p.Id == 2);

            // Act
            bool result = planetService.Edit(1, planet.Name, planet.Mass);

            // Assert
            Assert.False(result);
        }
Beispiel #3
0
        public void Edit_WithNotExistingName_ShouldReturnTrue()
        {
            // Arrange
            StarStuffDbContext db            = this.Database;
            PlanetService      planetService = new PlanetService(db);

            this.SeedDatabase(db);

            Planet planet = this.GetFakePlanets().First();

            // Act
            bool result = planetService.Edit(planet.Id, planet.Name, planet.Mass);

            // Assert
            Assert.True(result);
        }
Beispiel #4
0
        public void Edit_WithSameName_ShouldEditPlanet()
        {
            // Arrange
            StarStuffDbContext db            = this.Database;
            PlanetService      planetService = new PlanetService(db);

            this.SeedDatabase(db);

            Planet expected = this.GetFakePlanets().First();

            expected.Mass = 3.14;

            // Act
            planetService.Edit(expected.Id, expected.Name, expected.Mass);
            Planet actual = db.Planets.Find(expected.Id);

            // Assert
            this.ComparePlanets(expected, actual);
        }
Beispiel #5
0
        public void Edit_WithNotExistingName_ShouldEditPlanet()
        {
            // Arrange
            StarStuffDbContext db            = this.Database;
            PlanetService      planetService = new PlanetService(db);

            this.SeedDatabase(db);
            const int planetId = 1;

            Planet expected = new Planet
            {
                Id   = planetId,
                Name = "Not Existing 1",
                Mass = 20.5
            };

            // Act
            bool   result = planetService.Edit(planetId, expected.Name, expected.Mass);
            Planet actual = db.Planets.Find(planetId);

            // Assert
            this.ComparePlanets(expected, actual);
        }