public IActionResult GetOpenRestaurantByDate(DateTime searchDate) { var restaurantUC = new RestaurantUC(restoRepository); var result = restaurantUC.FindOpenRestaurantsByDate(searchDate); return(View("GetAllRestaurants", result)); }
public void FindOpenRestaurantsByDate_Should_Return_New_List_When_Any_Resto_Is_Open() { //Arrange var mock = new Mock <IRestoRepository>(); var schedules = new List <ScheduleDTO>(); var schedule = new ScheduleDTO { TimeOpen = DateTime.Now, TimeClosed = DateTime.Now.AddHours(3), DayOfWeek = (int)DateTime.Now.DayOfWeek }; schedules.Add(schedule); mock.Setup(x => x.GetAll()).Returns(new List <RestoDTO>() { new RestoDTO { City = "Bruxelles", Id = 1, Name = "R1", Schedules = new List <ScheduleDTO>() }, new RestoDTO { City = "Bruxelles", Id = 2, Name = "R2", Schedules = new List <ScheduleDTO>() }, new RestoDTO { City = "Liege", Id = 3, Name = "R3", Schedules = new List <ScheduleDTO>() }, }); RestaurantUC target = new RestaurantUC(mock.Object); //Act var result = target.FindOpenRestaurantsByDate(schedule.TimeOpen).ToList(); //Assert Assert.AreEqual(result.Count, 0); }