public IActionResult ById(long id) { var result = new GetMealById(Repository, id).Execute(); if (result == null) { return(NotFound()); } return(Ok(result)); }
public void ShouldFailFindingMealById() { var mockMealRepo = new Mock <IMealRepository>(); var date = DateTime.Now; var meal = new domain.Meal(date, "patates", 0); mockMealRepo.Setup(m => m.GetById(0)).Returns(meal); var getMealById = new GetMealById(mockMealRepo.Object, 1); var res = getMealById.Execute(); Assert.IsNull(res); }
public void ShouldFindMealById() { var mockMealRepo = new Mock <IMealRepository>(); var date = DateTime.Now; var meal = new domain.Meal(date, "patates", 0); mockMealRepo.Setup(m => m.GetById(0)).Returns(meal); var getMealById = new GetMealById(mockMealRepo.Object, 0); var res = getMealById.Execute(); Assert.NotNull(res); Assert.AreEqual("patates", res.Description); Assert.AreEqual(date, res.Date); }