コード例 #1
0
        public void Delete_by_id_When_airhostess_is_deleted_Then_other_entities_are_not_changed()
        {
            // Arrange
            var airhostessToDeleteId = 3;

            var service = new AirhostessService(UnitOfWork, AlwaysValidValidator);

            var airhostessesBeforeUpdate = AirportDbContext.Airhostess
                                           .Where(x => x.Id != airhostessToDeleteId).ToList();

            // Act
            service.Delete(airhostessToDeleteId);

            // Assert
            var airhostessesAfterUpdate = AirportDbContext.Airhostess
                                          .Where(x => x.Id != airhostessToDeleteId).ToList();

            Assert.AreEqual(airhostessesBeforeUpdate.Count, airhostessesAfterUpdate.Count);
            foreach (var beforeUpdate in airhostessesBeforeUpdate)
            {
                var afterUpdate = airhostessesAfterUpdate.FirstOrDefault(x => x.Id == beforeUpdate.Id);
                Assert.NotNull(afterUpdate);

                Assert.AreEqual(beforeUpdate.Id, afterUpdate.Id);
                Assert.AreEqual(beforeUpdate.FirstName, afterUpdate.FirstName);
                Assert.AreEqual(beforeUpdate.LastName, afterUpdate.LastName);
                Assert.AreEqual(beforeUpdate.BirthDate, afterUpdate.BirthDate);
                Assert.AreEqual(beforeUpdate.CrewId, afterUpdate.CrewId);
            }
        }
コード例 #2
0
        public void Delete_by_id_When_airhostess_is_deleted_Then_it_deletes_in_db()
        {
            // Arrange
            var airhostessToDeleteId = 3;

            var service = new AirhostessService(UnitOfWork, AlwaysValidValidator);

            // Act
            service.Delete(airhostessToDeleteId);

            // Assert
            var tryToFindDeletedAirhostess = AirportDbContext.Airhostess
                                             .FirstOrDefault(x => x.Id == airhostessToDeleteId);

            Assert.IsNull(tryToFindDeletedAirhostess);
        }