public async Task E_Update_EditNameRestaurant_NameRestaurantChangeInDb() { //Arrange var restaurantService = new RestaurantService(); var restaurant = new Restaurant() { ID = new Guid("10000000-0000-0000-0000-000000000000"), Name = "TestUpgarde", Grade = new Grade() { Score = 1 } }; restaurantsToDelete.Add(restaurant); restaurantService.Create(restaurantsToDelete.First()); restaurant.Name = "updateTest"; restaurant.Grade.Score = 5; restaurant.Address.Street = "test"; //Act await restaurantService.Update(restaurant); var updateResto = restaurantService.GetAll().Where(e => e.ID == restaurant.ID).FirstOrDefault(); //Assert Assert.AreEqual(restaurant.Name, updateResto.Name); Assert.AreEqual(restaurant.Grade.Score, updateResto.Grade.Score); Assert.AreEqual(restaurant.Address.Street, updateResto.Address.Street); //Clean up database await deleteTestResto(); }
public void Return_AllRestaurantsWhenMethodIsInvoced() { // Arrange var restaurantRepository = new Mock <IEfRepository <Restaurant> >(); var userRepository = new Mock <IEfRepository <User> >(); var tableRepository = new Mock <IEfRepository <Table> >(); var userRoleService = new Mock <IUserRoleService>(); var saveContext = new Mock <ISaveContext>(); IEnumerable <Restaurant> expectedResultCollection = new List <Restaurant>(); restaurantRepository.Setup(r => r.All).Returns(() => { return(expectedResultCollection.AsQueryable()); }); IRestaurantService restaurantService = new RestaurantService( restaurantRepository.Object, userRepository.Object, tableRepository.Object, userRoleService.Object, saveContext.Object); // Act IEnumerable <Restaurant> restaurantsResult = restaurantService.GetAll(); // Assert Assert.That(restaurantsResult, Is.EqualTo(expectedResultCollection)); }
public IActionResult Index() { var model = new HomeModel { Restaurants = _restaurantService.GetAll() }; return(View("~/Views/Restaurant/Home.cshtml", model)); }
public async Task Da_GetAll_AddARestaurant_NotNull() { //Arrange var restaurantService = new RestaurantService(); var countBefore = restaurantService.GetAll().Count(); restaurantsToDelete.Add(new Restaurant()); restaurantService.Create(restaurantsToDelete.Last()); //Act var result = restaurantService.GetAll(); //Assert Assert.AreNotEqual(countBefore, result); //Clean up database await deleteTestResto(); }
public async Task F_Delete_TakeFirstRestaurant_OneLessRestaurantInDb() { //Arrange var restaurantService = new RestaurantService(); restaurantsToDelete.Add(new Restaurant() { ID = new Guid("11000000-0000-0000-0000-000000000000") }); restaurantService.Create(restaurantsToDelete.First()); var count = restaurantService.GetAll().Count(); //Act await restaurantService.Delete(restaurantsToDelete.First().ID); //Assert Assert.AreNotEqual(count, restaurantService.GetAll().Count()); }
public async Task Dd_Get5BestScore_ListRestaurantBefore_ReturnList5BestScoredRestaurant() { //Arrange var restaurantService = new RestaurantService(); restaurantsToDelete.Add(new Restaurant() { Grade = new Grade() { Score = 1 } }); restaurantService.Create(restaurantsToDelete.Last()); restaurantsToDelete.Add(new Restaurant() { Grade = new Grade() { Score = 3 } }); restaurantService.Create(restaurantsToDelete.Last()); restaurantsToDelete.Add(new Restaurant() { Grade = new Grade() { Score = 5 } }); restaurantService.Create(restaurantsToDelete.Last()); restaurantsToDelete.Add(new Restaurant() { Grade = new Grade() { Score = 8 } }); restaurantService.Create(restaurantsToDelete.Last()); restaurantsToDelete.Add(new Restaurant() { Grade = new Grade() { Score = 9 } }); restaurantService.Create(restaurantsToDelete.Last()); var restosBefore = restaurantService.GetAll(); //Act var result = restaurantService.Get5BestScore(); //Assert //Assert.AreEqual(9, result.First().Grade.Score); Assert.AreNotEqual(restosBefore.First(), result.First()); //Clean up database await deleteTestResto(); }
public async Task C_Create_ANewRestaurant_NewRestaurantInDb() { //Arrange var resto = new Restaurant(); restaurantsToDelete.Add(resto); var restaurantService = new RestaurantService(); var count = restaurantService.GetAll().Count(); //Act restaurantService.Create(resto); //Assert Assert.AreNotEqual(count, restaurantService.GetAll().Count()); //Clean up database await deleteTestResto(); }
// // GET: Reservations // public ActionResult Index() // { // ReservationListViewModel model = new ReservationListViewModel(); // model.Reservations = new ReservationService().GetAll(u => u.UserId == AthenticationService.LoggedUser.Id).ToList(); // if (model.Reservations == null) // { // return RedirectToAction("Index", "Home"); // } // return View(model); // } private List <SelectListItem> GetRestaurants() { RestaurantService service = new RestaurantService(); List <SelectListItem> items = new List <SelectListItem>(); foreach (var item in service.GetAll().ToList()) { items.Add(new SelectListItem { Text = item.Name, Value = item.Id.ToString() }); } return(items); }
public ActionResult RestaurantList(Guid id) { ViewBag.resto = rs.GetAll().Where(m => m.Addresses.Any(c => c.CountryID == id)); return(View()); }
public IEnumerable <RestaurantDTO> ListRestaurante() { return(_restaurantService.GetAll()); }
public ActionResult Index() { var r = rs.GetAll(); return(View(r)); }
public ActionResult Index() { return(View(rs.GetAll())); }