Пример #1
0
        public void controlla_Ingredients_DeleteTest()
        {
            // Arrange
            IngredientsController controller = new IngredientsController();

            //Act
            //id dell'ingrediente che ha come descrizione "ingredientFotTestCreate"
            var idingredientBeforeDelete = from s in db.Ingredients
                                           .Where(x => x.Description.Equals("ingredientFotTestCreate"))
                                           select s.ID;

            //chiamo il controller per cancellare
            ActionResult result = controller.DeleteConfirmed(idingredientBeforeDelete.FirstOrDefault());

            //rileggo se esiste l'id dopo la cancellazione
            var idingredientAfterDelete = from s in db.Ingredients
                                          .Where(x => x.Description.Equals("ingredientFotTestCreate"))
                                          select s.ID;

            // Assert
            //mi aspetto che non ci sia l'id0
            Assert.AreEqual(0, idingredientAfterDelete.FirstOrDefault());
        }