Пример #1
0
 private ProgramServiceValidationEntity GetValidationEntity(
     EcaProgram program,
     Organization owner,
     OfficeSettings ownerOfficeSettings,
     Program parentProgram,
     List <int> regionTypesIds,
     List <int> inactiveRegionIds,
     List <OrganizationProgramDTO> parentProgramParentPrograms,
     List <int> allowedThemeIds,
     List <int> allowedGoalIds)
 {
     return(new ProgramServiceValidationEntity(
                programId: program.Id,
                name: program.Name,
                description: program.Description,
                regionLocationTypeIds: regionTypesIds,
                inactiveRegionIds: inactiveRegionIds,
                contactIds: program.ContactIds,
                owner: owner,
                themeIds: program.ThemeIds,
                goalIds: program.GoalIds,
                regionIds: program.RegionIds,
                categoryIds: program.FocusCategoryIds,
                objectiveIds: program.JustificationObjectiveIds,
                parentProgramId: program.ParentProgramId,
                parentProgram: parentProgram,
                ownerOfficeSettings: ownerOfficeSettings,
                parentProgramParentPrograms: parentProgramParentPrograms,
                allowedThemeIds: allowedThemeIds,
                allowedGoalIds: allowedGoalIds
                ));
 }
        public void TestConstructor_NullParentProgramParentPrograms()
        {
            var regionLocationTypeIds = new List <int> {
                1
            };
            var contactIds = new List <int> {
                1
            };
            var themeIds = new List <int> {
                1
            };
            var goalIds = new List <int> {
                1
            };
            var regionIds = new List <int> {
                1
            };
            var categoryIds = new List <int> {
                1
            };
            var objectiveIds = new List <int> {
                1
            };
            var inactiveRegionids = new List <int>();
            var focus             = new Focus();
            var owner             = new Organization();
            var parentProgramId   = 2;
            var parentProgram     = new Program();
            var name            = "hello";
            var description     = "desc";
            var programId       = 1;
            var officeSettings  = new OfficeSettings();
            var allowedThemeIds = new List <int>();
            var allowedGoalIds  = new List <int>();
            var entity          = new ProgramServiceValidationEntity(
                programId,
                name,
                description,
                regionLocationTypeIds,
                inactiveRegionids,
                contactIds,
                themeIds,
                goalIds,
                regionIds,
                categoryIds,
                objectiveIds,
                owner,
                officeSettings,
                parentProgramId,
                parentProgram,
                null,
                allowedThemeIds,
                allowedGoalIds
                );

            Assert.IsNotNull(entity.ParentProgramParentPrograms);
            Assert.IsNotNull(entity.InactiveRegionIds);
        }
        /// <summary>
        /// Creates a new ProjectServiceValidationEntity.
        /// </summary>
        /// <param name="updatedProject">The updated project.</param>
        /// <param name="projectToUpdate">The project to be updated.</param>
        /// <param name="locationsExist">The boolean value indicating whether all locations exist in the system.</param>
        /// <param name="categoriesExist">The boolean value indicating whether all categories exist in the system.</param>
        /// <param name="objectivesExist">The boolean value indicating whether all objectives exist in the system.</param>
        /// <param name="newInactiveLocations">The ids of locations that are inactive and were not previously set on the project.</param>
        /// <param name="goalsExist">The boolean value indicating whether all goals exist in the system.</param>
        /// <param name="themesExist">The boolean value indicating whether all themes exist in the system.</param>
        /// <param name="pointsOfContactExist">the boolean valud indicating whether all points of contact in the system.</param>
        /// <param name="numberOfCategories">The number of categories.</param>
        /// <param name="numberOfObjectives">The number of objectives.</param>
        /// <param name="officeSettings">The office settings.</param>
        /// <param name="allowedCategoryIds">The category ids the project can be assigned as deteremined by the parent program.</param>
        /// <param name="allowedObjectiveIds">The objective ids the project can be assigned as determined by the parent program.</param>
        /// <param name="regionLocationTypeIds">The location type ids for the given project regions.</param>
        public ProjectServiceUpdateValidationEntity(
            PublishedProject updatedProject,
            Project projectToUpdate,
            List <int> newInactiveLocations,
            bool goalsExist,
            bool themesExist,
            bool pointsOfContactExist,
            bool categoriesExist,
            bool objectivesExist,
            bool locationsExist,
            int numberOfObjectives,
            int numberOfCategories,
            IEnumerable <int> allowedCategoryIds,
            IEnumerable <int> allowedObjectiveIds,
            IEnumerable <int> regionLocationTypeIds,
            OfficeSettings officeSettings,
            IEnumerable <int> allowedThemeIds,
            IEnumerable <int> allowedGoalIds)
        {
            Contract.Requires(updatedProject != null, "The updated project must not be null.");
            Contract.Requires(projectToUpdate != null, "The project to update must not be null.");

            var updatedProjectStatus = ProjectStatus.GetStaticLookup(updatedProject.ProjectStatusId);

            if (updatedProjectStatus == null)
            {
                throw new UnknownStaticLookupException(String.Format("The project status with id [{0}] is not recognized.", updatedProject.ProjectStatusId));
            }
            Contract.Assert(ProjectStatus.GetStaticLookup(projectToUpdate.ProjectStatusId) != null, "The project to update should have a valid project status.");
            this.Name                    = updatedProject.Name;
            this.Description             = updatedProject.Description;
            this.GoalsExist              = goalsExist;
            this.ThemesExist             = themesExist;
            this.LocationsExist          = locationsExist;
            this.PointsOfContactExist    = pointsOfContactExist;
            this.CategoriesExist         = categoriesExist;
            this.ObjectivesExist         = objectivesExist;
            this.UpdatedProjectStatusId  = updatedProject.ProjectStatusId;
            this.SevisOrgId              = updatedProject.SevisOrgId;
            this.OriginalProjectStatusId = projectToUpdate.ProjectStatusId;
            this.StartDate               = updatedProject.StartDate;
            this.EndDate                 = updatedProject.EndDate;
            this.NumberOfCategories      = numberOfCategories;
            this.NumberOfObjectives      = numberOfObjectives;
            this.OfficeSettings          = officeSettings;
            this.CategoryIds             = updatedProject.CategoryIds;
            this.ObjectiveIds            = updatedProject.ObjectiveIds;
            this.AllowedCategoryIds      = allowedCategoryIds == null ? new List <int>() : allowedCategoryIds.Distinct();
            this.AllowedObjectiveIds     = allowedObjectiveIds == null ? new List <int>() : allowedObjectiveIds.Distinct();
            this.NewInactiveLocationIds  = newInactiveLocations == null ? new List <int>() : newInactiveLocations.Distinct();
            this.RegionLocationTypeIds   = regionLocationTypeIds == null ? new List <int>() : regionLocationTypeIds.Distinct();
            this.ThemeIds                = updatedProject.ThemeIds;
            this.GoalIds                 = updatedProject.GoalIds;
            this.AllowedThemeIds         = allowedThemeIds == null ? new List <int>() : allowedThemeIds.Distinct();
            this.AllowedGoalIds          = allowedGoalIds == null ? new List <int>() : allowedGoalIds.Distinct();
        }
Пример #4
0
        public void TestToString_HasSettings()
        {
            var officeSettings = new OfficeSettings();

            officeSettings.CategoryLabel       = "cat";
            officeSettings.FocusLabel          = "foc";
            officeSettings.IsCategoryRequired  = true;
            officeSettings.IsObjectiveRequired = true;
            officeSettings.JustificationLabel  = "just";
            officeSettings.MaximumRequiredFoci = 1;
            officeSettings.MinimumRequiredFoci = 1;
            officeSettings.ObjectiveLabel      = "obj";
            Assert.IsNotNull(officeSettings.ToString());
        }
 /// <summary>
 /// Creates a new ProgramServiceValidationEntity.
 /// </summary>
 /// <param name="programId">The id of the program.</param>
 /// <param name="name">The name of the program.</param>
 /// <param name="description">The description of the program.</param>
 /// <param name="regionLocationTypeIds">The region ids.</param>
 /// <param name="owner">The owner.</param>
 /// <param name="inactiveRegionIds">The regions by id that are inactive.</param>
 /// <param name="parentProgramId">The parent program id.</param>
 /// <param name="contactIds">The list of contacts by id.</param>
 /// <param name="parentProgram">The parent program.</param>
 /// <param name="goalIds">The goals by id.</param>
 /// <param name="regionIds">The regions by id.</param>
 /// <param name="themeIds">The themes by id.</param>
 /// <param name="categoryIds">The categories by id.</param>
 /// <param name="objectiveIds">The objectives by id.</param>
 /// <param name="ownerOfficeSettings">The office settings for the owner.</param>
 /// <param name="parentProgramParentPrograms">The list of parent programs for the given parent program.  In other words,
 /// the program may have a new parent program set, so to prevent circular references, the tree of programs for the parent program must
 /// be known and checked.</param>
 public ProgramServiceValidationEntity(
     int programId,
     string name,
     string description,
     List <int> regionLocationTypeIds,
     List <int> inactiveRegionIds,
     List <int> contactIds,
     List <int> themeIds,
     List <int> goalIds,
     List <int> regionIds,
     List <int> categoryIds,
     List <int> objectiveIds,
     Organization owner,
     OfficeSettings ownerOfficeSettings,
     int?parentProgramId,
     Program parentProgram,
     List <OrganizationProgramDTO> parentProgramParentPrograms,
     List <int> allowedThemeIds,
     List <int> allowedGoalIds)
 {
     this.ProgramId             = programId;
     this.RegionLocationTypeIds = regionLocationTypeIds;
     this.OwnerOrganization     = owner;
     this.ParentProgramId       = parentProgramId;
     this.ParentProgram         = parentProgram;
     this.Name                        = name;
     this.Description                 = description;
     this.ContactIds                  = contactIds;
     this.GoalIds                     = goalIds;
     this.ThemeIds                    = themeIds;
     this.RegionIds                   = regionIds;
     this.CategoryIds                 = categoryIds;
     this.ObjectiveIds                = objectiveIds;
     this.OwnerOfficeSettings         = ownerOfficeSettings;
     this.InactiveRegionIds           = inactiveRegionIds == null ? new List <int>() : inactiveRegionIds.Distinct();
     this.ParentProgramParentPrograms = parentProgramParentPrograms ?? new List <OrganizationProgramDTO>();
     this.AllowedThemeIds             = allowedThemeIds == null ? new List <int>() : allowedThemeIds.Distinct();
     this.AllowedGoalIds              = allowedGoalIds == null ? new List <int>() : allowedGoalIds.Distinct();
 }
Пример #6
0
 private ProjectServiceUpdateValidationEntity GetUpdateValidationEntity(
     PublishedProject publishedProject,
     Project projectToUpdate,
     bool goalsExist,
     bool themesExist,
     bool pointsOfContactExist,
     bool categoriesExist,
     bool objectivesExist,
     bool locationsExist,
     int numberOfCategories,
     int numberOfObjectives,
     List <int> allowedCategoryIds,
     List <int> allowedObjectiveIds,
     List <int> newInactiveLocationIds,
     List <int> regionLocationTypeIds,
     OfficeSettings settings,
     List <int> allowedThemeIds,
     List <int> allowedGoalIds)
 {
     return(new ProjectServiceUpdateValidationEntity(
                updatedProject: publishedProject,
                projectToUpdate: projectToUpdate,
                goalsExist: goalsExist,
                themesExist: themesExist,
                locationsExist: locationsExist,
                pointsOfContactExist: pointsOfContactExist,
                categoriesExist: categoriesExist,
                objectivesExist: objectivesExist,
                numberOfCategories: numberOfCategories,
                numberOfObjectives: numberOfObjectives,
                officeSettings: settings,
                allowedCategoryIds: allowedCategoryIds,
                allowedObjectiveIds: allowedObjectiveIds,
                regionLocationTypeIds: regionLocationTypeIds,
                newInactiveLocations: newInactiveLocationIds,
                allowedThemeIds: allowedThemeIds,
                allowedGoalIds: allowedGoalIds
                ));
 }
Пример #7
0
        public void TestConstructor_NullRegionLocationTypeIds()
        {
            var updatedProject = new PublishedProject(
                new User(1),
                projectId: 1,
                name: "name",
                description: "description",
                projectStatusId: ProjectStatus.Other.Id,
                sevisOrgId: "abcde1234567890",
                themeIds: null,
                goalIds: null,
                pointsOfContactIds: null,
                locationIds: null,
                categoryIds: null,
                objectiveIds: null,
                regionIds: null,
                startDate: DateTimeOffset.UtcNow.AddDays(1.0),
                endDate: DateTimeOffset.UtcNow,
                visitorTypeId: 1,
                usParticipantsEst: null,
                nonUsParticipantsEst: null,
                usParticipantsActual: null,
                nonUsParticipantsActual: null);
            var project = new Project
            {
                ProjectStatusId = ProjectStatus.Draft.Id
            };
            var        goalsExist             = true;
            var        themesExist            = true;
            var        pointsOfContactExist   = true;
            var        categoriesExist        = true;
            var        objectivesExist        = true;
            var        locationsExist         = true;
            var        numberOfCategories     = 10;
            var        numberOfObjectives     = 20;
            var        officeSettings         = new OfficeSettings();
            List <int> allowedCategoryIds     = new List <int>();
            List <int> allowedObjectiveIds    = new List <int>();
            List <int> newInactiveLocationIds = new List <int>();
            List <int> regionLocationTypeIds  = null;
            List <int> allowedThemeIds        = new List <int>();
            List <int> allowedGoalIds         = new List <int>();

            var instance = new ProjectServiceUpdateValidationEntity(
                updatedProject,
                project,
                newInactiveLocationIds,
                goalsExist,
                themesExist,
                pointsOfContactExist,
                categoriesExist,
                objectivesExist,
                locationsExist,
                numberOfObjectives,
                numberOfCategories,
                allowedCategoryIds,
                allowedObjectiveIds,
                regionLocationTypeIds,
                officeSettings,
                allowedThemeIds,
                allowedGoalIds);

            Assert.IsNotNull(instance.RegionLocationTypeIds);
        }
Пример #8
0
        public void TestConstructor()
        {
            var updatedProject = new PublishedProject(
                new User(1),
                projectId: 1,
                name: "name",
                description: "description",
                projectStatusId: ProjectStatus.Other.Id,
                sevisOrgId: "abcde1234567890",
                themeIds: null,
                goalIds: null,
                pointsOfContactIds: null,
                categoryIds: new List <int> {
                1
            },
                objectiveIds: new List <int> {
                2
            },
                locationIds: new List <int> {
                3
            },
                regionIds: new List <int> {
                4
            },
                startDate: DateTimeOffset.UtcNow.AddDays(1.0),
                endDate: DateTimeOffset.UtcNow,
                visitorTypeId: 1,
                usParticipantsEst: null,
                nonUsParticipantsEst: null,
                usParticipantsActual: null,
                nonUsParticipantsActual: null);

            var project = new Project
            {
                ProjectStatusId = ProjectStatus.Draft.Id
            };
            var goalsExist           = true;
            var themesExist          = true;
            var pointsOfContactExist = true;
            var categoriesExist      = true;
            var objectivesExist      = true;
            var locationsExist       = true;
            var numberOfCategories   = 10;
            var numberOfObjectives   = 20;
            var officeSettings       = new OfficeSettings();
            var allowedCategoryIds   = new List <int> {
                1
            };
            var allowedObjectiveIds = new List <int> {
                2
            };
            var newInactiveLocationIds = new List <int> {
                3
            };
            List <int> regionLocationTypeIds = new List <int> {
                LocationType.Region.Id
            };
            var allowedThemeIds = new List <int> {
                1
            };
            var allowedGoalIds = new List <int> {
                1
            };

            var instance = new ProjectServiceUpdateValidationEntity(
                updatedProject,
                project,
                newInactiveLocationIds,
                goalsExist,
                themesExist,
                pointsOfContactExist,
                categoriesExist,
                objectivesExist,
                locationsExist,
                numberOfObjectives,
                numberOfCategories,
                allowedCategoryIds,
                allowedObjectiveIds,
                regionLocationTypeIds,
                officeSettings,
                allowedThemeIds,
                allowedGoalIds);

            Assert.AreEqual(updatedProject.Name, instance.Name);
            Assert.AreEqual(updatedProject.Description, instance.Description);
            Assert.AreEqual(updatedProject.StartDate, instance.StartDate);
            Assert.AreEqual(updatedProject.EndDate, instance.EndDate);
            Assert.AreEqual(updatedProject.ProjectStatusId, instance.UpdatedProjectStatusId);
            Assert.AreEqual(updatedProject.SevisOrgId, instance.SevisOrgId);
            Assert.AreEqual(project.ProjectStatusId, instance.OriginalProjectStatusId);
            Assert.AreEqual(goalsExist, instance.GoalsExist);
            Assert.AreEqual(themesExist, instance.ThemesExist);
            Assert.AreEqual(pointsOfContactExist, instance.PointsOfContactExist);
            Assert.AreEqual(numberOfCategories, instance.NumberOfCategories);
            Assert.AreEqual(numberOfObjectives, instance.NumberOfObjectives);
            CollectionAssert.AreEqual(allowedCategoryIds.ToList(), instance.AllowedCategoryIds.ToList());
            CollectionAssert.AreEqual(allowedObjectiveIds.ToList(), instance.AllowedObjectiveIds.ToList());
            CollectionAssert.AreEqual(updatedProject.ObjectiveIds.ToList(), instance.ObjectiveIds.ToList());
            CollectionAssert.AreEqual(updatedProject.CategoryIds.ToList(), instance.CategoryIds.ToList());
            CollectionAssert.AreEqual(newInactiveLocationIds, instance.NewInactiveLocationIds.ToList());
            Assert.IsTrue(Object.ReferenceEquals(officeSettings, instance.OfficeSettings));
            CollectionAssert.AreEqual(allowedThemeIds.ToList(), instance.AllowedThemeIds.ToList());
            CollectionAssert.AreEqual(allowedGoalIds.ToList(), instance.AllowedGoalIds.ToList());
        }
Пример #9
0
        public void TestToString_NoSettings()
        {
            var officeSettings = new OfficeSettings();

            Assert.IsNotNull(officeSettings.ToString());
        }
        public void TestConstructor()
        {
            var regionLocationTypeIds = new List <int> {
                1
            };
            var contactIds = new List <int> {
                1
            };
            var themeIds = new List <int> {
                1
            };
            var goalIds = new List <int> {
                1
            };
            var regionIds = new List <int> {
                1
            };
            var categoryIds = new List <int> {
                1
            };
            var objectiveIds = new List <int> {
                1
            };
            var inactiveRegionids = new List <int> {
                1, 1, 1
            };
            var parentPrograms  = new List <OrganizationProgramDTO>();
            var focus           = new Focus();
            var owner           = new Organization();
            var parentProgramId = 2;
            var parentProgram   = new Program();
            var name            = "hello";
            var description     = "desc";
            var programId       = 1;
            var officeSettings  = new OfficeSettings();
            var allowedThemeIds = new List <int> {
                1, 1, 1
            };
            var allowedGoalIds = new List <int> {
                1, 1, 1
            };
            var entity = new ProgramServiceValidationEntity(
                programId,
                name,
                description,
                regionLocationTypeIds,
                inactiveRegionids,
                contactIds,
                themeIds,
                goalIds,
                regionIds,
                categoryIds,
                objectiveIds,
                owner,
                officeSettings,
                parentProgramId,
                parentProgram,
                parentPrograms,
                allowedThemeIds,
                allowedGoalIds
                );

            Assert.IsTrue(Object.ReferenceEquals(regionLocationTypeIds, entity.RegionLocationTypeIds));
            Assert.IsTrue(Object.ReferenceEquals(contactIds, entity.ContactIds));
            Assert.IsTrue(Object.ReferenceEquals(themeIds, entity.ThemeIds));
            Assert.IsTrue(Object.ReferenceEquals(goalIds, entity.GoalIds));
            Assert.IsTrue(Object.ReferenceEquals(categoryIds, entity.CategoryIds));
            Assert.IsTrue(Object.ReferenceEquals(objectiveIds, entity.ObjectiveIds));
            Assert.IsTrue(Object.ReferenceEquals(owner, entity.OwnerOrganization));
            Assert.IsTrue(Object.ReferenceEquals(parentProgram, entity.ParentProgram));
            Assert.IsTrue(Object.ReferenceEquals(name, entity.Name));
            Assert.IsTrue(Object.ReferenceEquals(description, entity.Description));
            Assert.IsTrue(Object.ReferenceEquals(officeSettings, entity.OwnerOfficeSettings));
            Assert.IsTrue(Object.ReferenceEquals(parentPrograms, entity.ParentProgramParentPrograms));
            CollectionAssert.AreEqual(inactiveRegionids.Distinct().ToList(), entity.InactiveRegionIds.ToList());

            Assert.AreEqual(parentProgramId, entity.ParentProgramId);
            Assert.AreEqual(programId, entity.ProgramId);
            CollectionAssert.AreEqual(allowedThemeIds.Distinct().ToList(), entity.AllowedThemeIds.ToList());
            CollectionAssert.AreEqual(allowedGoalIds.Distinct().ToList(), entity.AllowedGoalIds.ToList());
        }