public void GetAllRestaurants_Should_Return_Proper_Collection() { //Arrange var mock = new Mock <IRestoRepository>(); mock.Setup(x => x.GetAll()).Returns(new List <RestoDTO>() { new RestoDTO { City = "Bruxelles", Id = 1, Name = "R1" }, new RestoDTO { City = "Bruxelles", Id = 2, Name = "R2" }, new RestoDTO { City = "Liege", Id = 3, Name = "R3" }, }); RestaurantUC target = new RestaurantUC(mock.Object); //Act var result = target.GetAllRestaurants().ToList(); //Assert Assert.AreEqual(result.Count, 3); Assert.AreEqual(result[0].Id, 1); Assert.AreEqual(result[2].Name, "R3"); }
public IActionResult GetAllRestaurantsAdmin() { var restaurantUC = new RestaurantUC(restoRepository); var result = restaurantUC.GetAllRestaurants(); if (result != null || result.ToList().Count == 0) { return(View(result)); } else { return(RedirectToAction("", "Sorry! There is any restaurant in our database")); } }