Exemple #1
0
        public void AllViewModelFieldsAreSetFromConstructorTest()
        {
            // Arrange
            var project = TestFramework.TestProject.Create();

            // Act
            var viewModel = new BasicsViewModel(project);

            // Assert
            Assert.That(viewModel.ProjectID, Is.EqualTo(project.ProjectID));
            Assert.That(viewModel.ProjectName, Is.EqualTo(project.ProjectName));
            Assert.That(viewModel.ProjectDescription, Is.EqualTo(project.ProjectDescription));
        }
Exemple #2
0
        public ProposalSectionsStatus(Models.Project project)
        {
            var basicsResults = new BasicsViewModel(project).GetValidationResults();

            IsBasicsSectionComplete = !basicsResults.Any();

            var customAttributeResults = new CustomAttributesViewModel(project).GetValidationResults();

            IsCustomAttributesSectionComplete = !customAttributeResults.Any();

            var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults();

            IsProjectLocationSimpleSectionComplete = !locationSimpleValidationResults.Any();

            IsProjectLocationDetailedSectionComplete = IsBasicsSectionComplete;

            var regionIDs = project.ProjectRegions
                            .Select(x => x.DNRUplandRegionID).ToList();
            var editProjectRegionsValidationResults = new EditProjectRegionsViewModel(regionIDs,
                                                                                      project.NoRegionsExplanation).GetValidationResults();

            IsRegionSectionComplete = !editProjectRegionsValidationResults.Any();

            var priorityLandscapeIDs = project.ProjectPriorityLandscapes
                                       .Select(x => x.PriorityLandscapeID).ToList();
            var editProjectPriorityLandscapesValidationResults = new EditProjectPriorityLandscapesViewModel(priorityLandscapeIDs,
                                                                                                            project.NoPriorityLandscapesExplanation).GetValidationResults();

            IsPriorityLandscapeSectionComplete = !editProjectPriorityLandscapesValidationResults.Any();

            var performanceMeasureValidationResults =
                new ExpectedPerformanceMeasureValuesViewModel(project).GetValidationResults();

            IsPerformanceMeasureSectionComplete = !performanceMeasureValidationResults.Any();

            var efValidationResults = new ExpectedFundingViewModel(project.ProjectGrantAllocationRequests.ToList(),
                                                                   project.EstimatedTotalCost,
                                                                   project.ProjectFundingSourceNotes,
                                                                   project.ProjectFundingSources.ToList())
                                      .GetValidationResults();

            IsExpectedFundingSectionComplete = !efValidationResults.Any();

            var proposalClassificationSimples   = ProjectCreateController.GetProjectClassificationSimples(project);
            var classificationValidationResults =
                new EditProposalClassificationsViewModel(proposalClassificationSimples).GetValidationResults();

            IsClassificationsComplete = !classificationValidationResults.Any();

            IsNotesSectionComplete = IsBasicsSectionComplete; //there is no validation required on Notes
        }
Exemple #3
0
        public void UpdateModelTest()
        {
            // Arrange
            var project   = TestFramework.TestProject.Create();
            var viewModel = new BasicsViewModel(project);

            viewModel.ProjectName        = TestFramework.MakeTestName(GeneralUtility.NameOf(() => viewModel.ProjectName), ProjectFirmaModels.Models.Project.FieldLengths.ProjectName);
            viewModel.ProjectDescription = TestFramework.MakeTestName(GeneralUtility.NameOf(() => viewModel.ProjectDescription), ProjectFirmaModels.Models.Project.FieldLengths.ProjectDescription);

            // Act
            viewModel.UpdateModel(project, TestFramework.TestFirmaSession.Create());

            // Assert
            Assert.That(project.ProjectName, Is.EqualTo(viewModel.ProjectName));
            Assert.That(project.ProjectDescription, Is.EqualTo(viewModel.ProjectDescription));
        }
        /// <summary>
        /// Method to check whether each section in a proposal is complete
        ///
        /// </summary>
        /// <param name="project"></param>
        /// <param name="geospatialAreaTypes">Geospatial areas are defined per tenant, this is passed to check if the tenant has any and are complete</param>
        public ProposalSectionsStatus(ProjectFirmaModels.Models.Project project, List <GeospatialAreaType> geospatialAreaTypes, FirmaSession currentFirmaSession)
        {
            // Basics section
            var basicsResults = new BasicsViewModel(project).GetValidationResults();

            IsBasicsSectionComplete = !basicsResults.Any();

            // Custom Attributes section
            var customAttributesValidationResults = project.ValidateCustomAttributes(currentFirmaSession).GetWarningMessages();

            IsProjectCustomAttributesSectionComplete = !customAttributesValidationResults.Any();

            // Project Location simple section
            var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults();

            IsProjectLocationSimpleSectionComplete = !locationSimpleValidationResults.Any();

            // Project location detailed section
            IsProjectLocationDetailedSectionComplete = IsBasicsSectionComplete;

            // Geospatial Area section
            if (geospatialAreaTypes.Any())
            {
                var isGeospatialAreaSectionComplete = true;
                foreach (var geospatialAreaType in geospatialAreaTypes)
                {
                    var geospatialAreaIDs = project.ProjectGeospatialAreas.Where(x => x.GeospatialArea.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID).Select(x => x.GeospatialAreaID).ToList();
                    var editGeospatialAreaValidationResults = new EditProjectGeospatialAreasViewModel(geospatialAreaIDs, project.ProjectGeospatialAreaTypeNotes.SingleOrDefault(x => x.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID)?.Notes).GetValidationResults();
                    if (editGeospatialAreaValidationResults.Any())
                    {
                        isGeospatialAreaSectionComplete = false;
                        break;
                    }
                }

                IsGeospatialAreaSectionComplete = isGeospatialAreaSectionComplete;
            }
            else
            {
                IsGeospatialAreaSectionComplete = true;
            }

            // Performance Measure section
            IsPerformanceMeasureSectionComplete = IsBasicsSectionComplete;

            // Project FundingSource Budget and Cost Type section
            var calendarYearRange = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears();
            var allProjectRelevantCostTypesAsSimples = project.GetAllProjectRelevantCostTypesAsSimples(ProjectRelevantCostTypeGroup.Budgets);
            var budgetValidationResults =
                new EditProjectFundingSourceBudgetByCostTypeViewModel(project, calendarYearRange,
                                                                      allProjectRelevantCostTypesAsSimples).GetValidationResults();

            IsExpectedFundingSectionComplete = !budgetValidationResults.Any();

            // Classifications section
            var proposalClassificationSimples   = ProjectCreateController.GetProjectClassificationSimples(project);
            var classificationValidationResults = new EditProposalClassificationsViewModel(proposalClassificationSimples, project).GetValidationResults();

            IsClassificationsComplete = !classificationValidationResults.Any();

            // Assessment section
            IsAssessmentComplete = ProjectCreateController.GetProjectAssessmentQuestionSimples(project).All(simple => simple.Answer.HasValue);

            // Notes section
            IsNotesSectionComplete = IsBasicsSectionComplete; //there is no validation required on Notes
        }