Esempio n. 1
0
        public void Teardown()
        {
            try
            {
                userid = 2;
                controller.ModelState.Clear();

                var result =
                    controller.DeleteDishes(item.id, userid);
                IngredientsController controllerIng = new IngredientsController();
                var result2 =
                    controllerIng.GetIngredient().ToList();

                Ingredient temping = result2.Find(e => e.name == "testpepperoni");
                if (temping != null)
                {
                    controllerIng.DeleteIngredient(temping.id, userid);
                }

                temping = result2.Find(e => e.name == "ost");
                if (temping != null)
                {
                    controllerIng.DeleteIngredient(temping.id, userid);
                }
            }
            catch (Exception e) { }
        }
        public void Teardown()
        {
            try
            {
                userid = 2;
                controller.ModelState.Clear();

                var result =
                    controller.DeleteIngredient(item.id, userid);
            }
            catch { }
        }
Esempio n. 3
0
        public void PutDishes_StringNoIngredient()
        {
            IngredientsController ingcontroller      = new IngredientsController();
            List <Ingredient>     ingredientswithID  = ingcontroller.GetIngredient().ToList();
            List <Ingredient>     ingredienstodelete = new List <Ingredient>();
            Ingredient            temping            = item.Ingredient.First();

            ingredienstodelete = ingredientswithID.Where(e => e.name == temping.name).ToList();
            foreach (var ing in ingredienstodelete)
            {
                ingcontroller.DeleteIngredient(ing.id, 2);
            }
            item.Ingredient = null;
            var specialpricenull = controller.PutDishess(item.id, 2, item);

            Assert.AreEqual("There was no ingredient attached", specialpricenull);
        }
Esempio n. 4
0
        public void DeleteIngredient_InvalidId_ReturnsNotFound()
        {
            // Arrange
            int invalidRecipeId = 2;

            ingredientsServiceMock = new Mock <IIngredientsService>();
            ingredientsServiceMock
            .Setup(m => m.GetById(invalidRecipeId))
            .Returns(null as IngredientDto);

            ingredientsController = new IngredientsController(ingredientsServiceMock.Object, mapper);

            // Act
            var result = ingredientsController.DeleteIngredient(invalidRecipeId);

            // Assert
            Assert.IsTrue(result.GetType() == typeof(NotFoundResult));
        }