public void GetMealsByDateDNETest() { IList<FoodEntry> foodEntries = null; mealRepositoryMock.Setup(t => t.GetFoodEntries(It.IsAny<DateTime>())).Returns(foodEntries); MealController controller = new MealController(mealRepositoryMock.Object); var results = controller.Get(DateTime.Now) as IEnumerable<MealEntryViewModel>; Assert.IsNotNull(results); Assert.AreEqual(0, results.Count()); }
public void GetMealsByDateExistsTest() { mealRepositoryMock.Setup(t => t.GetFoodEntries(It.IsAny<DateTime>())).Returns(new List<FoodEntry>(){ new FoodEntry(){ CalculatedNutrients = new List<Nutrient>(){ new Nutrient(){ Description = "nut1" }, new Nutrient(){ Description = "nut1" }, new Nutrient(){ Description = "nut1" } }, Date = DateTime.Now, FoodId = "1", Name = "food1", SelectedServing = new Serving(){ Amount = 1}, ServingId = "1", ServingSize = 5, Id = 1 }, new FoodEntry(){ CalculatedNutrients = new List<Nutrient>(){ new Nutrient(){ Description = "nut1" }, new Nutrient(){ Description = "nut1" }, new Nutrient(){ Description = "nut1" } }, Date = DateTime.Now, FoodId = "1", Name = "food2", SelectedServing = new Serving(){ Amount = 1}, ServingId = "1", ServingSize = 5, Id = 2 } }); MealController controller = new MealController(mealRepositoryMock.Object); var results = controller.Get(DateTime.Now) as IEnumerable<MealEntryViewModel>; Assert.IsNotNull(results); Assert.AreEqual(2, results.Count()); Assert.AreEqual("food2", results.First(t => t.Id == 2).Name); }