public void Current_ShouldRenderDefaultViewWithCorrectModel() { var mapperStub = new Mock <IMapper>(); var weekScheduleServiceStub = new Mock <IWeekScheduleService>(); var sut = new PublicScheduleController(mapperStub.Object, weekScheduleServiceStub.Object); var currentSchedule = new WeekSchedule(); var model = new CurrentScheduleViewModel(); weekScheduleServiceStub.Setup(x => x.GetCurrentSchedule()).Returns(currentSchedule); mapperStub.Setup(x => x.Map <CurrentScheduleViewModel>(It.IsAny <WeekSchedule>())).Returns(model); sut .WithCallTo(c => c.Current()) .ShouldRenderDefaultView() .WithModel(model); }
public void Current_ShouldCAllMapperOnceWithCurrentSchedule() { var mapperStub = new Mock <IMapper>(); var weekScheduleServiceStub = new Mock <IWeekScheduleService>(); var sut = new PublicScheduleController(mapperStub.Object, weekScheduleServiceStub.Object); var currentSchedule = new WeekSchedule(); var model = new CurrentScheduleViewModel(); weekScheduleServiceStub.Setup(x => x.GetCurrentSchedule()).Returns(currentSchedule); mapperStub.Setup(x => x.Map <CurrentScheduleViewModel>(It.IsAny <WeekSchedule>())).Returns(model); sut .WithCallTo(c => c.Current()); mapperStub.Verify(x => x.Map <CurrentScheduleViewModel>(currentSchedule), Times.Once); }
public ActionResult CurrentSchedule() { var schedules = GetSchedules(CurrentUserInfo.id); var dayState = new DayState { DayOff = null }; var hours = new HoursAtWork { ScheduleID = 0, HourFrom = 8, HourTo = 16, HoursFrom = GetHoursFrom(), HoursTo = GetHoursTo() }; var model = new CurrentScheduleViewModel { Schedules = schedules, DayState = dayState, HoursAtWork = hours }; return(View(model)); }