public IActionResult GetCuisineById(int id) { var result = cuisineUC.GetCuisineById(id); if (result != null) { return(View(result)); } else { return(RedirectToAction("Error", new { errorMessage = "Sorry! We don't find this cuisine" })); } }
public void GetCuisineById_Null_When_Not_Found() { //Arrange var mock = new Mock <ICuisineRepository>(); mock.Setup(x => x.GetById(25)); CuisineUC target = new CuisineUC(mock.Object); //Act var result = target.GetCuisineById(25); //Assert Assert.AreEqual(null, result); Assert.IsNull(result); }
public void GetCuisineById_Should_Return_Valid_Data() { //Arrange var mock = new Mock <ICuisineRepository>(); mock.Setup(x => x.GetById(1)).Returns( new CuisineDTO { Id = 1, Name = "Japonais" } ); CuisineUC target = new CuisineUC(mock.Object); //Act var result = target.GetCuisineById(1); //Assert Assert.AreEqual(result.Id, 1); Assert.AreEqual(result.Name, "Japonais"); }