Пример #1
0
        public void MapFromDatabaseEntity_NullEntity_ReturnNull()
        {
            //Act
            var response = ProjectInformationDTO.MapFromDatabaseEntity(null);

            //Assert
            Assert.IsNull(response);
        }
        public void Update(Guid id, ProjectInformationDTO projectInformationDTO)
        {
            if (id != projectInformationDTO.ProjectId)
            {
                throw new BusinessValidationException("The Id informed does not match the Id in the Entity");
            }

            _repository.Update(id, ProjectInformation.MapFromDomainEntity(projectInformationDTO));
        }
        public void Update_ProjectIdAndCapitalPlanDTO_CallRepositoryToUpdateContent()
        {
            //Arrange
            var id = new Guid("2509d0dc-fa61-48a5-8650-684592539742");

            var capitalPlanDTO = new ProjectInformationDTO
            {
                ProjectId = id
            };

            //Act
            _service.Update(id, capitalPlanDTO);

            //Assert
            _repository.Received(1).Update(id, Arg.Is <ProjectInformation>(c => c.ProjectId == id));
        }
        public async Task <IActionResult> Put(Guid id, [FromBody] ProjectInformationDTO projectInformationDTO)
        {
            if (projectInformationDTO == null)
            {
                return(BadRequest("Could not convert the content of the Body to a Project Information."));
            }

            _projectInformationService.Update(id, projectInformationDTO);

            var response = await _unitOfWork.SaveChangesAsync();

            if (response == 0)
            {
                return(NotFound());
            }

            return(NoContent());
        }
        public void Update_CapitalPlanIdDoesNotMatchProjectIdInEntity_ThrowBusinessValidationException()
        {
            //Arrange
            var id        = new Guid("2509d0dc-fa61-48a5-8650-684592539742");
            var anotherId = new Guid("b80d67ad-112d-4368-9074-d5bf0e3c0fa0");

            var capitalPlanDTO = new ProjectInformationDTO
            {
                ProjectId = id
            };

            //Act
            var ex = Assert.Throws <BusinessValidationException>(() =>
            {
                _service.Update(anotherId, capitalPlanDTO);
            });

            //Assert
            Assert.IsNotNull(ex);
            StringAssert.Contains("The Id informed does not match the Id in the Entity", ex.Message);
        }
Пример #6
0
        public void Put_ProjectIdProjectInformationDTO_ReturnsNoContent()
        {
            //Arrange
            var id = new Guid("8e1e1161-d83d-4962-8094-4cee0a9dc210");

            var projectInformationDTO = new ProjectInformationDTO
            {
                ProjectId = id
            };

            _unitOfWork.SaveChangesAsync()
            .Returns(Task.FromResult(1));

            //Act
            var response      = _controller.Put(id, projectInformationDTO).Result;
            var contentResult = response as NoContentResult;

            //Assert
            Assert.IsNotNull(contentResult);
            _service.Received(1).Update(id, projectInformationDTO);
        }
Пример #7
0
        public void Get_ExistingProjectId_ReturnProjectDTO()
        {
            //Arrange
            var id = new Guid("2509d0dc-fa61-48a5-8650-684592539742");

            var projectDTO = new ProjectInformationDTO
            {
                ProjectId = id
            };

            _service.Get(id)
            .Returns(projectDTO);

            //Act
            var response = _controller.Get(id) as ObjectResult;

            //Assert
            Assert.IsNotNull(response);
            var resultAsDTO = (ProjectInformationDTO)response.Value;

            Assert.IsNotNull(resultAsDTO);
            Assert.AreEqual(id, resultAsDTO.ProjectId);
        }
Пример #8
0
        public void MapFromDatabaseEntity_ValidEntity_ReturnValidDTOEntity()
        {
            //Arrange
            var projectInformation = new ProjectInformation
            {
                ProjectId          = new Guid("b58b6a58-2064-4c71-9b3d-c8c4514159a9"),
                ProjectName        = "Test",
                ProjectDescription = "Test Description",
                Scope                                        = "Scope",
                Region                                       = "region",
                Country                                      = "United States",
                Location                                     = "Location",
                LocationCode                                 = "Location Code",
                EntityCode                                   = "Entity Code",
                Department                                   = "Department",
                Top10Project                                 = "Top 10 Project",
                ProjectStatus                                = "ProjectStatus",
                ProjectOwner                                 = "ProjectOwner",
                ProjectSponsor                               = "Project Sponsor",
                BauOrRe                                      = "BAU or RE",
                FiscalYearEnd                                = 2020,
                BudgetedOrUnbudgeted                         = "Budgeted",
                CurrentProjectPhase                          = "Current Project Phase",
                UsableFloorArea                              = 1400,
                HeadCount                                    = 45,
                LeasedOrOwned                                = "Leased",
                CapitalExpense                               = "Capital/Expense",
                FacilityType                                 = "Facility Type",
                ProjectType                                  = "Project Type",
                CriticalityRationale                         = "Criticality Rationale",
                CriticalityRationaleLevel2                   = "Criticality Rationale Level 2",
                RequiredOrDiscretionary                      = "Required Or Discretionary",
                CurrentLeaseExpiryDate                       = 2024,
                NewLeaseExpiryDate                           = 2025,
                OnboardingStatus                             = "Onboarding Status",
                OnboardingDate                               = new DateTime(2019, 08, 01),
                OnboardingDeckLink                           = "Onboarding Deck Link",
                Rollover                                     = true,
                ApprovedBudget                               = 1012.45D,
                PercentComplete                              = 35,
                LastUpdated                                  = new DateTime(2019, 08, 08),
                Highlights                                   = "Highlights",
                ActionsNextTwoWeeks                          = "Action Next Two Weeks",
                RisksAndIssues                               = "Risks and issues",
                ProjectStartReceiveBusinessRequest           = "Project Start Receive Business Request",
                CompleteProjectAnalysis                      = "Complete Project Analysis",
                SubmitProjectRequestForAnalysis              = "Submit Project Request For Analysis",
                CurrentMileStonePercentComplete              = 40,
                DesignBriefGatewayDocumentApproval           = "Document Approval",
                LeaseExecution                               = "Lease Execution",
                DesignComplete                               = "Design Complete",
                PurchaseCeAvTechCircuitsSecurityEquipment    = "Purchase CE/AV/Tech/Circuits/Security Equipment",
                AwardOfficeFurnitureContracts                = "Award Office",
                StartOnSite                                  = "Start On Site",
                TechnologyRoomMepCommissioningIST            = "Technology Room",
                TechnologyRoomHandoverComplete               = "Technology Handover",
                CommenceInstallDesktopAndAVEquipment         = "Commence Install",
                HandoverToFacilities                         = "Handover To Facilities",
                CommenceMoveIsAndUse                         = "Commence Move In",
                InstallationComplete                         = true,
                ReceiveCloseoutDocumentationAndFinalAccounts = "Receive Closeout",
                ProjectComplete                              = true
            };

            //Act
            var response = ProjectInformationDTO.MapFromDatabaseEntity(projectInformation);

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(projectInformation.ProjectId, response.ProjectId);
            Assert.AreEqual(projectInformation.ProjectName, response.ProjectName);
            Assert.AreEqual(projectInformation.ProjectDescription, response.ProjectDescription);
            Assert.AreEqual(projectInformation.Scope, response.Scope);
            Assert.AreEqual(projectInformation.Region, response.Region);
            Assert.AreEqual(projectInformation.Country, response.Country);
            Assert.AreEqual(projectInformation.Location, response.Location);
            Assert.AreEqual(projectInformation.LocationCode, response.LocationCode);
            Assert.AreEqual(projectInformation.EntityCode, response.EntityCode);
            Assert.AreEqual(projectInformation.Department, response.Department);
            Assert.AreEqual(projectInformation.Top10Project, response.Top10Project);
            Assert.AreEqual(projectInformation.ProjectStatus, response.ProjectStatus);
            Assert.AreEqual(projectInformation.ProjectOwner, response.ProjectOwner);
            Assert.AreEqual(projectInformation.ProjectSponsor, response.ProjectSponsor);
            Assert.AreEqual(projectInformation.BauOrRe, response.BauOrRe);
            Assert.AreEqual(projectInformation.FiscalYearEnd, response.FiscalYearEnd);
            Assert.AreEqual(projectInformation.BudgetedOrUnbudgeted, response.BudgetedOrUnbudgeted);
            Assert.AreEqual(projectInformation.CurrentProjectPhase, response.CurrentProjectPhase);
            Assert.AreEqual(projectInformation.UsableFloorArea, response.UsableFloorArea);
            Assert.AreEqual(projectInformation.HeadCount, response.HeadCount);
            Assert.AreEqual(projectInformation.LeasedOrOwned, response.LeasedOrOwned);
            Assert.AreEqual(projectInformation.CapitalExpense, response.CapitalExpense);
            Assert.AreEqual(projectInformation.FacilityType, response.FacilityType);
            Assert.AreEqual(projectInformation.ProjectType, response.ProjectType);
            Assert.AreEqual(projectInformation.CriticalityRationale, response.CriticalityRationale);
            Assert.AreEqual(projectInformation.CriticalityRationaleLevel2, response.CriticalityRationaleLevel2);
            Assert.AreEqual(projectInformation.RequiredOrDiscretionary, response.RequiredOrDiscretionary);
            Assert.AreEqual(projectInformation.CurrentLeaseExpiryDate, response.CurrentLeaseExpiryDate);
            Assert.AreEqual(projectInformation.NewLeaseExpiryDate, response.NewLeaseExpiryDate);
            Assert.AreEqual(projectInformation.OnboardingStatus, response.OnboardingStatus);
            Assert.AreEqual(projectInformation.OnboardingDate, response.OnboardingDate);
            Assert.AreEqual(projectInformation.OnboardingDeckLink, response.OnboardingDeckLink);
            Assert.AreEqual(projectInformation.Rollover, response.Rollover);
            Assert.AreEqual(projectInformation.ApprovedBudget, response.ApprovedBudget);
            Assert.AreEqual(projectInformation.PercentComplete, response.PercentComplete);
            Assert.AreEqual(projectInformation.LastUpdated, response.LastUpdated);
            Assert.AreEqual(projectInformation.Highlights, response.Highlights);
            Assert.AreEqual(projectInformation.ActionsNextTwoWeeks, response.ActionsNextTwoWeeks);
            Assert.AreEqual(projectInformation.RisksAndIssues, response.RisksAndIssues);
            Assert.AreEqual(projectInformation.ProjectStartReceiveBusinessRequest, response.ProjectStartReceiveBusinessRequest);
            Assert.AreEqual(projectInformation.CompleteProjectAnalysis, response.CompleteProjectAnalysis);
            Assert.AreEqual(projectInformation.SubmitProjectRequestForAnalysis, response.SubmitProjectRequestForAnalysis);
            Assert.AreEqual(projectInformation.CurrentMileStonePercentComplete, response.CurrentMileStonePercentComplete);
            Assert.AreEqual(projectInformation.DesignBriefGatewayDocumentApproval, response.DesignBriefGatewayDocumentApproval);
            Assert.AreEqual(projectInformation.LeaseExecution, response.LeaseExecution);
            Assert.AreEqual(projectInformation.DesignComplete, response.DesignComplete);
            Assert.AreEqual(projectInformation.PurchaseCeAvTechCircuitsSecurityEquipment, response.PurchaseCeAvTechCircuitsSecurityEquipment);
            Assert.AreEqual(projectInformation.AwardOfficeFurnitureContracts, response.AwardOfficeFurnitureContracts);
            Assert.AreEqual(projectInformation.StartOnSite, response.StartOnSite);
            Assert.AreEqual(projectInformation.TechnologyRoomMepCommissioningIST, response.TechnologyRoomMepCommissioningIST);
            Assert.AreEqual(projectInformation.TechnologyRoomHandoverComplete, response.TechnologyRoomHandoverComplete);
            Assert.AreEqual(projectInformation.CommenceInstallDesktopAndAVEquipment, response.CommenceInstallDesktopAndAVEquipment);
            Assert.AreEqual(projectInformation.HandoverToFacilities, response.HandoverToFacilities);
            Assert.AreEqual(projectInformation.CommenceMoveIsAndUse, response.CommenceMoveIsAndUse);
            Assert.AreEqual(projectInformation.InstallationComplete, response.InstallationComplete);
            Assert.AreEqual(projectInformation.ReceiveCloseoutDocumentationAndFinalAccounts, response.ReceiveCloseoutDocumentationAndFinalAccounts);
            Assert.AreEqual(projectInformation.ProjectComplete, response.ProjectComplete);
        }
Пример #9
0
        public static ProjectInformation MapFromDomainEntity(ProjectInformationDTO projectProjectInformation)
        {
            if (projectProjectInformation == null)
            {
                return(null);
            }

            return(new ProjectInformation
            {
                Highlights = projectProjectInformation.Highlights,
                InstallationComplete = projectProjectInformation.InstallationComplete,
                LeasedOrOwned = projectProjectInformation.LeasedOrOwned,
                ProjectName = projectProjectInformation.ProjectName,
                StartOnSite = projectProjectInformation.StartOnSite,
                RisksAndIssues = projectProjectInformation.RisksAndIssues,
                Top10Project = projectProjectInformation.Top10Project,
                ActionsNextTwoWeeks = projectProjectInformation.ActionsNextTwoWeeks,
                OnboardingDeckLink = projectProjectInformation.OnboardingDeckLink,
                BudgetedOrUnbudgeted = projectProjectInformation.BudgetedOrUnbudgeted,
                UsableFloorArea = projectProjectInformation.UsableFloorArea,
                OnboardingStatus = projectProjectInformation.OnboardingStatus,
                DesignBriefGatewayDocumentApproval = projectProjectInformation.DesignBriefGatewayDocumentApproval,
                EntityCode = projectProjectInformation.EntityCode,
                Region = projectProjectInformation.Region,
                SubmitProjectRequestForAnalysis = projectProjectInformation.SubmitProjectRequestForAnalysis,
                Department = projectProjectInformation.Department,
                CommenceInstallDesktopAndAVEquipment = projectProjectInformation.CommenceInstallDesktopAndAVEquipment,
                CurrentMileStonePercentComplete = projectProjectInformation.CurrentMileStonePercentComplete,
                ReceiveCloseoutDocumentationAndFinalAccounts = projectProjectInformation.ReceiveCloseoutDocumentationAndFinalAccounts,
                ProjectSponsor = projectProjectInformation.ProjectSponsor,
                CompleteProjectAnalysis = projectProjectInformation.CompleteProjectAnalysis,
                Location = projectProjectInformation.Location,
                NewLeaseExpiryDate = projectProjectInformation.NewLeaseExpiryDate,
                ProjectStatus = projectProjectInformation.ProjectStatus,
                CapitalExpense = projectProjectInformation.CapitalExpense,
                TechnologyRoomHandoverComplete = projectProjectInformation.TechnologyRoomHandoverComplete,
                ProjectOwner = projectProjectInformation.ProjectOwner,
                FiscalYearEnd = projectProjectInformation.FiscalYearEnd,
                DesignComplete = projectProjectInformation.DesignComplete,
                ProjectComplete = projectProjectInformation.ProjectComplete,
                CommenceMoveIsAndUse = projectProjectInformation.CommenceMoveIsAndUse,
                CriticalityRationale = projectProjectInformation.CriticalityRationale,
                LeaseExecution = projectProjectInformation.LeaseExecution,
                OnboardingDate = projectProjectInformation.OnboardingDate,
                ApprovedBudget = projectProjectInformation.ApprovedBudget,
                PurchaseCeAvTechCircuitsSecurityEquipment = projectProjectInformation.PurchaseCeAvTechCircuitsSecurityEquipment,
                ProjectType = projectProjectInformation.ProjectType,
                ProjectDescription = projectProjectInformation.ProjectDescription,
                Country = projectProjectInformation.Country,
                CriticalityRationaleLevel2 = projectProjectInformation.CriticalityRationaleLevel2,
                Rollover = projectProjectInformation.Rollover,
                AwardOfficeFurnitureContracts = projectProjectInformation.AwardOfficeFurnitureContracts,
                RequiredOrDiscretionary = projectProjectInformation.RequiredOrDiscretionary,
                TechnologyRoomMepCommissioningIST = projectProjectInformation.TechnologyRoomMepCommissioningIST,
                FacilityType = projectProjectInformation.FacilityType,
                LocationCode = projectProjectInformation.LocationCode,
                ProjectStartReceiveBusinessRequest = projectProjectInformation.ProjectStartReceiveBusinessRequest,
                HeadCount = projectProjectInformation.HeadCount,
                CurrentProjectPhase = projectProjectInformation.CurrentProjectPhase,
                HandoverToFacilities = projectProjectInformation.HandoverToFacilities,
                PercentComplete = projectProjectInformation.PercentComplete,
                CurrentLeaseExpiryDate = projectProjectInformation.CurrentLeaseExpiryDate,
                BauOrRe = projectProjectInformation.BauOrRe,
                Scope = projectProjectInformation.Scope,
                ProjectId = projectProjectInformation.ProjectId,
                LastUpdated = projectProjectInformation.LastUpdated
            });
        }