Example #1
0
        public void GetIngredientsReturnsOkResult()
        {
            //Act
            var result = controller.GetIngredients();

            //Assert
            Assert.IsType <OkObjectResult>(result);
        }
Example #2
0
        public void GetIngredients_Empty_ReturnsOk()
        {
            // Arrange
            ingredientsServiceMock = new Mock <IIngredientsService>();
            ingredientsServiceMock
            .Setup(m => m.GetAll())
            .Returns(new List <IngredientDto>());
            ingredientsController = new IngredientsController(ingredientsServiceMock.Object, mapper);

            // Act
            var result = ingredientsController.GetIngredients();

            // Assert
            Assert.IsTrue(result.GetType() == typeof(OkObjectResult));
        }
        public void GetAllIngredients_FromService_ReturnsAllIngredients()
        {
            var ingredients = IngredientsTestData();

            var mockDataService = new Mock <IDataService>();

            mockDataService.Setup(x => x.GetIngredients())
            .Returns(ingredients);

            var controller = new IngredientsController(mockDataService.Object);

            var result        = controller.GetIngredients();
            var contentResult = result as OkObjectResult;

            Assert.Equal(ingredients, result);
        }
        public void GetIngredientsTest()
        {
            List <Ingredient> expectedList = new List <Ingredient>();
            Ingredient        ingredient1  = new Ingredient
            {
                Id   = 1,
                Name = "Name1"
            };
            Ingredient ingredient2 = new Ingredient
            {
                Id   = 2,
                Name = "Name2"
            };

            expectedList.Add(ingredient1);
            expectedList.Add(ingredient2);
            _ingredientsService.Setup(i => i.GetIngredients()).Returns(expectedList);

            List <Ingredient> resultList = _ingredientsController.GetIngredients();

            Assert.AreEqual(expectedList, resultList);
        }