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

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

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

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

            const int discoveryId = 1;

            this.SeedDiscovery(db, true);

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

            // Act
            bool result = planetService.Create(discoveryId, expected.Name, expected.Mass);

            // Assert
            Assert.True(result);
        }
예제 #3
0
        public void Create_WithNotExistingName_ShouldAddPlanet()
        {
            // Arrange
            StarStuffDbContext db            = this.Database;
            PlanetService      planetService = new PlanetService(db);

            const int discoveryId = 1;

            this.SeedDiscovery(db, true);

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

            // Act
            planetService.Create(discoveryId, expected.Name, expected.Mass);
            Planet actual = db.Planets.First();

            // Assert
            Assert.Equal(1, db.Planets.Count());
            this.ComparePlanets(expected, actual);
        }