public void Create()
        {
            // Arrange
            IngredientsController controller = new IngredientsController();

            // Act
            ViewResult result = controller.Create() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
        public async Task Create_ReturnViewResult()
        {
            //Arrange
            _mockService
            .MockCreateAsync()
            .MockGetByIdAsync(new Ingredient());

            //Act
            var result = await _controller.Create(_testIngredient);

            //Assert
            var viewResult = Assert.IsType <OkObjectResult>(result);
            var model      = Assert.IsAssignableFrom <Ingredient>(viewResult.Value);

            _mockService.Verify();
        }
Exemple #3
0
        public void controlla_Ingredients_CreateTest()
        {
            // Arrange
            IngredientsController controller = new IngredientsController();

            //Act
            //rilancio la creazione dell'ingrediente che ha come descrizione "ingredientFotTestCreate"

            Ingredients ingredientFotTestCreate = new Ingredients()
            {
                Description = "ingredientFotTestCreate",
                Quantity    = 1000
            };

            ActionResult result = controller.Create(ingredientFotTestCreate);

            var idingredientFotTestCreate = from s in db.Ingredients
                                            .Where(x => x.Description.Equals("ingredientFotTestCreate"))
                                            select s.ID;

            // Assert
            //mi aspetto, che la selzione in base alla descrizione mi restituisca un ID
            Assert.IsNotNull(idingredientFotTestCreate.FirstOrDefault());
        }