public void GetRestaurantsByRestaurantManager_Should_Return_Valid_Data() { //Arrange var mock = new Mock <IRestoRepository>(); mock.Setup(x => x.GetRestaurantsByRestaurantManager("1")).Returns(new List <RestoDTO>() { new RestoDTO { City = "Bruxelles", Id = 1, Name = "R1", UserManagerId = "1" }, new RestoDTO { City = "Liege", Id = 2, Name = "R2", UserManagerId = "1" }, } ); RestaurantUC target = new RestaurantUC(mock.Object); //Act var result = target.GetRestaurantsByRestaurantManager("1").ToList(); //Assert Assert.AreEqual(result[0].Id, 1); Assert.AreEqual(result[0].City, "Bruxelles"); Assert.AreEqual(result[1].Name, "R2"); Assert.AreEqual(result.Count, 2); }
public IActionResult GetRestaurantsByRestaurantManager() { var restaurantUC = new RestaurantUC(restoRepository); var result = restaurantUC.GetRestaurantsByRestaurantManager(User.FindFirst(ClaimTypes.NameIdentifier).Value).ToList(); if (result.ToList().Count != 0) { return(View(result)); } else { return(RedirectToAction("Error", new { errorMessage = "Sorry! You don't have any restaurant" })); } }
public void GetRestaurantsByRestaurantManager_Should_Return_Empty_List_If_Param_Null() { //Arrange var mock = new Mock <IRestoRepository>(); mock.Setup(x => x.GetRestaurantsByRestaurantManager("1")).Returns(new List <RestoDTO>() { new RestoDTO { City = "Bruxelles", Id = 1, Name = "R1", UserManagerId = "1" }, new RestoDTO { City = "Liege", Id = 2, Name = "R2", UserManagerId = "1" }, } ); RestaurantUC target = new RestaurantUC(mock.Object); //Act var result = target.GetRestaurantsByRestaurantManager("").ToList(); //Assert Assert.AreEqual(result.Count, 0); }