public async Task Details_ReturnNotFound_WhenIdIsNull()
        {
            //Arrange

            //Act
            var result = await _controller.Details(null);

            //Assert
            var viewResult = Assert.IsType <NotFoundResult>(result);
        }
Пример #2
0
        public void controlla_Ingredients_DetailsTest()
        {
            // Arrange
            IngredientsController controller = new IngredientsController();

            //Act
            //imposta il recupero dell'ingrediente id 1
            ActionResult result = controller.Details(1);

            // Assert
            //mi aspetto, ad esempio come ritorno dopo la chiamata per id 1 ingrediente che description=malts
            string Description = ((Ingredients)((ViewResultBase)result).Model).Description;

            Assert.AreEqual("malts", Description);
        }
Пример #3
0
        public async Task Details_ReturnsIngredientDetail()
        {
            // Arrange
            var ingredientId = 1;

            var mockLogger = new Mock <ILogger <IngredientsController> >();

            var controller = new IngredientsController(_context, mockLogger.Object);

            // Act
            var result = await controller.Details(ingredientId);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Null(viewResult.ViewName);
            Assert.NotNull(viewResult.ViewData);
        }