public void GetAllMealsByMealTypeId_Should_Return_Proper_Collection()
        {
            //Arrange
            var mock    = new Mock <IMealRepository>();
            var myMeals = new List <MealDTO>
            {
                new MealDTO
                {
                    Id       = 1,
                    Name     = "Salade César",
                    MealType = new MealTypeDTO()
                },
                new MealDTO
                {
                    Id       = 2,
                    Name     = "Mac N Cheese",
                    MealType = new MealTypeDTO()
                }
            };

            mock.Setup(x => x.GetMealsByMealTypeId(1)).Returns(myMeals);
            MealUC target = new MealUC(mock.Object);

            //Act
            var result = target.GetAllMealsByMealTypeId(1).ToList();

            //Assert
            Assert.AreEqual(result.Count, 2);
            Assert.AreEqual(result[0].Id, 1);
            Assert.AreEqual(result[1].Name, "Mac N Cheese");
        }
        public void GetAllMealsByMealTypeId_Should_Return_EmptyList_When_Not_Found()
        {
            //Arrange
            var mock = new Mock <IMealRepository>();

            mock.Setup(x => x.GetMealsByMealTypeId(1)).Returns(new List <MealDTO>());
            MealUC target = new MealUC(mock.Object);

            //Act
            var result = target.GetAllMealsByMealTypeId(1).ToList();

            //Assert
            Assert.AreEqual(0, result.Count);
        }
        public IActionResult GetAllMealsByMealTypeId(int Id)
        {
            var result  = mealUC.GetAllMealsByMealTypeId(Id);
            int restoId = 0;

            if (result.Count > 0)
            {
                restoId = mealUC.GetRestoIdByMealId(result.Last().Id);
            }

            ViewData["MealTypeId"] = Id;
            ViewData["RestoId"]    = restoId;
            if (result != null || result.ToList().Count == 0)
            {
                return(View(result));
            }
            else
            {
                return(RedirectToAction("Error",
                                        new { errorMessage = "Sorry! There is any meal in our database" }));
            }
        }