public void ProjectUpdateYearRangesTest() { var projectUpdate = TestFramework.TestProjectUpdate.Create(); projectUpdate.ProjectStageID = ProjectStage.Completed.ProjectStageID; var warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.ImplementationStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.CompletionYearIsRequired)); projectUpdate.CompletionYear = 2007; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.ImplementationStartYearIsRequired)); Assert.That(!warningMessages.Contains(BasicsValidationResult.CompletionYearIsRequired)); projectUpdate.ImplementationStartYear = 2010; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(!warningMessages.Contains(BasicsValidationResult.ImplementationStartYearIsRequired)); Assert.That(!warningMessages.Contains(BasicsValidationResult.CompletionYearIsRequired)); Assert.That(warningMessages.Contains(FirmaValidationMessages.CompletionYearGreaterThanEqualToImplementationStartYear)); projectUpdate.ImplementationStartYear = 2006; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(!warningMessages.Contains(FirmaValidationMessages.CompletionYearGreaterThanEqualToImplementationStartYear)); // This should always be the next calendar year, I believe -- SLG 1/2/2020 (writing after this test started crashing) int nextCalendarYear = DateTime.Now.Year + 1; projectUpdate.ProjectStageID = ProjectStage.PlanningDesign.ProjectStageID; projectUpdate.PlanningDesignStartYear = nextCalendarYear; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(!warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearShouldBeLessThanCurrentYear)); Assert.That(warningMessages.Contains(FirmaValidationMessages.ImplementationStartYearGreaterThanPlanningDesignStartYear)); projectUpdate.ProjectStageID = ProjectStage.Implementation.ProjectStageID; projectUpdate.ImplementationStartYear = nextCalendarYear; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.ImplementationStartYearShouldBeLessThanCurrentYear)); }
public void ProjectUpdateYearRangesTest() { var projectUpdate = TestFramework.TestProjectUpdate.Create(); projectUpdate.ProjectStageID = ProjectStage.Completed.ProjectStageID; var warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.ImplementationStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.CompletionYearIsRequired)); projectUpdate.CompletionYear = 2007; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.ImplementationStartYearIsRequired)); Assert.That(!warningMessages.Contains(BasicsValidationResult.CompletionYearIsRequired)); projectUpdate.ImplementationStartYear = 2010; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(!warningMessages.Contains(BasicsValidationResult.ImplementationStartYearIsRequired)); Assert.That(!warningMessages.Contains(BasicsValidationResult.CompletionYearIsRequired)); Assert.That(warningMessages.Contains(FirmaValidationMessages.CompletionYearGreaterThanEqualToImplementationStartYear)); projectUpdate.ImplementationStartYear = 2006; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(!warningMessages.Contains(FirmaValidationMessages.CompletionYearGreaterThanEqualToImplementationStartYear)); projectUpdate.ProjectStageID = ProjectStage.PlanningDesign.ProjectStageID; projectUpdate.PlanningDesignStartYear = 2022; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(!warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearIsRequired)); Assert.That(warningMessages.Contains(BasicsValidationResult.PlanningDesignStartYearShouldBeLessThanCurrentYear)); Assert.That(warningMessages.Contains(FirmaValidationMessages.ImplementationStartYearGreaterThanPlanningDesignStartYear)); projectUpdate.ProjectStageID = ProjectStage.Implementation.ProjectStageID; projectUpdate.ImplementationStartYear = 2022; warningMessages = new BasicsValidationResult(projectUpdate).GetWarningMessages(); Assert.That(warningMessages.Contains(BasicsValidationResult.ImplementationStartYearShouldBeLessThanCurrentYear)); }
public BasicsViewData(FirmaSession currentFirmaSession , ProjectFirmaModels.Models.ProjectUpdate projectUpdate, IEnumerable <ProjectStage> projectStages , ProjectUpdateStatus projectUpdateStatus, BasicsValidationResult basicsValidationResult) : base(currentFirmaSession, projectUpdate.ProjectUpdateBatch, projectUpdateStatus, basicsValidationResult.GetWarningMessages(), ProjectUpdateSection.Basics.ProjectUpdateSectionDisplayName) { ProjectUpdate = projectUpdate; TaxonomyLeafDisplayName = projectUpdate.ProjectUpdateBatch.Project.TaxonomyLeaf.GetDisplayName(); ProjectStages = projectStages.OrderBy(x => x.SortOrder).ToSelectListWithEmptyFirstRow(x => x.ProjectStageID.ToString(CultureInfo.InvariantCulture), y => y.ProjectStageDisplayName); ProjectStagesModels = projectStages; PlanningDesignStartYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay).ToList(); ImplementationStartYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay).ToList(); CompletionYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay).ToList(); RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshBasics(Project)); DiffUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.DiffBasics(Project)); SectionCommentsViewData = new SectionCommentsViewData(projectUpdate.ProjectUpdateBatch.BasicsComment, projectUpdate.ProjectUpdateBatch.IsReturned()); StartYearForTotalCostCalculation = projectUpdate.StartYearForTotalCostCalculations(); TenantUsesFiscalYears = MultiTenantHelpers.UseFiscalYears(); }
public BasicsViewData(Person currentPerson, Models.ProjectUpdate projectUpdate, IEnumerable <ProjectStage> projectStages, UpdateStatus updateStatus, BasicsValidationResult basicsValidationResult, IEnumerable <Models.ProjectCustomAttributeType> projectCustomAttributeTypes, List <Models.FocusArea> focusAreas) : base(currentPerson, projectUpdate.ProjectUpdateBatch, updateStatus, basicsValidationResult.GetWarningMessages(), ProjectUpdateSection.Basics.ProjectUpdateSectionDisplayName) { ProjectUpdate = projectUpdate; ProjectTypeDisplayName = projectUpdate.ProjectUpdateBatch.Project.ProjectType.DisplayName; ProjectStages = projectStages.OrderBy(x => x.SortOrder).ToSelectListWithEmptyFirstRow(x => x.ProjectStageID.ToString(CultureInfo.InvariantCulture), y => y.ProjectStageDisplayName); FocusAreas = focusAreas.OrderBy(x => x.FocusAreaName) .ToSelectListWithEmptyFirstRow(x => x.FocusAreaID.ToString(CultureInfo.InvariantCulture), y => y.FocusAreaName); PlannedDateRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay); ImplementationStartYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay); CompletionDateRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay); RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshBasics(Project)); DiffUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.DiffBasics(Project)); SectionCommentsViewData = new SectionCommentsViewData(projectUpdate.ProjectUpdateBatch.BasicsComment, projectUpdate.ProjectUpdateBatch.IsReturned); ProjectCustomAttributeTypes = projectCustomAttributeTypes; }