예제 #1
0
        public static CapitalPlanDTO MapFromDatabaseEntity(CapitalPlan projectCapitalPlan)
        {
            if (projectCapitalPlan == null)
            {
                return(null);
            }

            return(new CapitalPlanDTO
            {
                Id = projectCapitalPlan.Id,                 //TODO: create Unit Test to cover this line
                Rollover = projectCapitalPlan.Rollover,
                BusinessDriver = projectCapitalPlan.BusinessDriver,
                ProjectId = projectCapitalPlan.ProjectId,
                LeaseExpiry = projectCapitalPlan.LeaseExpiry,
                StartDate = projectCapitalPlan.StartDate,
                Group = projectCapitalPlan.Group,
                PartOfPBASubmission = projectCapitalPlan.PartOfPBASubmission,
                Priority = projectCapitalPlan.Priority,
                EndDate = projectCapitalPlan.EndDate,
                BusinessPriority = projectCapitalPlan.BusinessPriority,
                RiskToBusinessByNotDoingIt = projectCapitalPlan.RiskToBusinessByNotDoingIt,
                RolloverCategory = projectCapitalPlan.RolloverCategory,
                BusinessRequirementsDone = projectCapitalPlan.BusinessRequirementsDone,
                Theme = projectCapitalPlan.Theme,
                Comments = projectCapitalPlan.Comments
            });
        }
예제 #2
0
        public void Update(Guid id, CapitalPlanDTO capitalPlanDTO)
        {
            if (id != capitalPlanDTO.ProjectId)
            {
                throw new BusinessValidationException("The Id informed does not match the Id in the Entity");
            }

            _repository.Update(id, CapitalPlan.MapFromDomainEntity(capitalPlanDTO));
        }
예제 #3
0
        public void Update(Guid id, CapitalPlan capitalPlan)
        {
            var entityInContext = _context.CapitalPlans.FirstOrDefault(c => c.ProjectId == id);

            if (entityInContext == null)
            {
                return;
            }

            _context.Entry(entityInContext).CurrentValues.SetValues(capitalPlan);
            _context.Entry(entityInContext).State = EntityState.Modified;
        }
예제 #4
0
        public void MapFromDomainEntity_ValidEntity_ReturnDTOEntity()
        {
            //Arrange
            var capitalPlan = new CapitalPlanDTO
            {
                Id                         = Guid.NewGuid(),
                ProjectId                  = new Guid("b58b6a58-2064-4c71-9b3d-c8c4514159a9"),
                Priority                   = 1,
                Rollover                   = false,
                RolloverCategory           = 0,
                PartOfPBASubmission        = false,
                BusinessPriority           = 1,
                Theme                      = "Theme",
                BusinessDriver             = "Business Driver",
                Group                      = "Group",
                LeaseExpiry                = "Lease Expiry",
                StartDate                  = new DateTime(2018, 08, 01),
                EndDate                    = new DateTime(2020, 08, 01),
                RiskToBusinessByNotDoingIt = "Risk to Business",
                BusinessRequirementsDone   = false,
                Comments                   = "Comments"
            };

            //Act
            var response = CapitalPlan.MapFromDomainEntity(capitalPlan);

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(capitalPlan.Id, response.Id);
            Assert.AreEqual(capitalPlan.ProjectId, response.ProjectId);
            Assert.AreEqual(capitalPlan.Priority, response.Priority);
            Assert.AreEqual(capitalPlan.Rollover, response.Rollover);
            Assert.AreEqual(capitalPlan.RolloverCategory, response.RolloverCategory);
            Assert.AreEqual(capitalPlan.PartOfPBASubmission, response.PartOfPBASubmission);
            Assert.AreEqual(capitalPlan.BusinessPriority, response.BusinessPriority);
            Assert.AreEqual(capitalPlan.Theme, response.Theme);
            Assert.AreEqual(capitalPlan.BusinessDriver, response.BusinessDriver);
            Assert.AreEqual(capitalPlan.Group, response.Group);
            Assert.AreEqual(capitalPlan.LeaseExpiry, response.LeaseExpiry);
            Assert.AreEqual(capitalPlan.StartDate, response.StartDate);
            Assert.AreEqual(capitalPlan.EndDate, response.EndDate);
            Assert.AreEqual(capitalPlan.RiskToBusinessByNotDoingIt, response.RiskToBusinessByNotDoingIt);
            Assert.AreEqual(capitalPlan.BusinessRequirementsDone, response.BusinessRequirementsDone);
            Assert.AreEqual(capitalPlan.Comments, response.Comments);
        }
        public void Get_ProjectId_ReturnsProjectDTO()
        {
            //Arrange
            var id = new Guid("2509d0dc-fa61-48a5-8650-684592539742");

            var project = new CapitalPlan
            {
                ProjectId = id
            };

            _repository.Get(id).Returns(project);

            //Act
            var response = _service.Get(id);

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(id, response.ProjectId);
        }