public void SetupVisualsBySearchOption_OneProjectSupportingForecastWithNoProjectCompanyFocus_AppliesSupportsProjectsNoFocusDisplayHandler() { // Arrange var forecastMonth = new ForecastOverviewForecastMonth { Forecasts = new List <ForecastOverviewForecast>() }; // Projectsupporting forecast var projectSupportingForecastMock = CreateWorkdayForecastMock(new ForecastType { Id = 2, SupportsProjectHours = true }); forecastMonth.Forecasts.Add(projectSupportingForecastMock.Object); var sut = Fixture.Create <ForecastOverviewSearchOptions>(); sut.SelectedCompany = null; sut.SelectedProject = null; // Act sut.SetupVisualsBySearchOption(forecastMonth, 1); // Assert projectSupportingForecastMock.VerifySet(x => x.DisplayHandler = It.IsAny <SupportsProjectsNoFocusDisplayHandler>()); }
/// <summary> /// Updates /// </summary> /// <param name="vm"></param> /// <param name="source"></param> /// <param name="projectForecastTypeId"></param> public void CreateForecastMonths(IForecastOverviewViewModel vm, IList <ForecastMonthDto> source, int projectForecastTypeId) { foreach (var forecastMonthDto in source) { var usrMonth = new ForecastOverviewForecastMonth { UserId = forecastMonthDto.UserId, UserName = forecastMonthDto.UserName, Forecasts = new List <ForecastOverviewForecast>(forecastMonthDto.ForecastDtos != null ? forecastMonthDto.ForecastDtos.Select(x => x.ToClient()) : new List <ForecastOverviewForecast>()) }; // Add missing non-work (weekend/vaccation) days (not stored on server) foreach (var forecastDate in vm.Dates.Where(x => !usrMonth.Forecasts.Any(y => y.Date.Equals(x)))) { usrMonth.Forecasts.Add(new ForecastOverviewForecast { Date = forecastDate }); } usrMonth.Forecasts = usrMonth.Forecasts.OrderBy(x => x.Date.Date).ToList(); vm.UserRegistrations.Add(usrMonth); } }
public void SetupVisualsBySearchOption_OneForecastForEachDisplayHandlerType_AppliesTheExpectedDisplayHandlers() { // Arrange const int projectForecastTypeId = 1; var projectForecastType = new ForecastType { Id = projectForecastTypeId }; var projectSupportingForecastType = new ForecastType { Id = 2, SupportsProjectHours = true }; var nonProjectSupportingForecastType = new ForecastType { Id = 3, SupportsProjectHours = false }; var forecastMonth = new ForecastOverviewForecastMonth { Forecasts = new List <ForecastOverviewForecast>() }; // Non workday forecast var nonWorkDayForecastMock = CreateMock <ForecastOverviewForecast>(); nonWorkDayForecastMock.SetupGet(x => x.IsWorkDay).Returns(false); forecastMonth.Forecasts.Add(nonWorkDayForecastMock.Object); // Project forecast var projectForecastMock = CreateWorkdayForecastMock(projectForecastType); forecastMonth.Forecasts.Add(projectForecastMock.Object); // Projectsupporting forecast var projectSupportingForecastMock = CreateWorkdayForecastMock(projectSupportingForecastType); forecastMonth.Forecasts.Add(projectSupportingForecastMock.Object); // Non projectsupporting forecast var nonProjectSupportingForecastMock = CreateWorkdayForecastMock(nonProjectSupportingForecastType); forecastMonth.Forecasts.Add(nonProjectSupportingForecastMock.Object); var sut = Fixture.Create <ForecastOverviewSearchOptions>(); sut.SelectedTabIndex = 0; // Indicates that searching by registration // Act sut.SetupVisualsBySearchOption(forecastMonth, projectForecastTypeId); // Assert nonWorkDayForecastMock.VerifySet(x => x.DisplayHandler = It.IsAny <EmptyDisplayHandler>()); projectForecastMock.VerifySet(x => x.DisplayHandler = It.IsAny <PureProjectTypeDisplayHandler>()); projectSupportingForecastMock.VerifySet(x => x.DisplayHandler = It.IsAny <SupportsProjectsWithFocusDisplayHandler>()); nonProjectSupportingForecastMock.VerifySet(x => x.DisplayHandler = It.IsAny <NonProjectSupportingDisplayHandler>()); }