Ejemplo n.º 1
0
        public void RemoveRisk(string nameOfInsuredObject, Risk risk, DateTime validTill, DateTime effectiveDate)
        {
            var policyId = IdGenerator.ConstructPolicyId(nameOfInsuredObject, effectiveDate);

            var policyModel = _policyRepository.Get(policyId);

            if (validTill.Date > policyModel.ValidTill.Date)
            {
                throw new RiskRemovalDateException();
            }

            var riskId = IdGenerator.ConstructRiskId(risk.Name, nameOfInsuredObject, effectiveDate);

            var riskModel = _riskRepository.Get(riskId);

            var updatedRiskModel = new RiskModel
            {
                Name                = riskModel.Name,
                ValidFrom           = riskModel.ValidFrom,
                PolicyEffectiveDate = riskModel.PolicyEffectiveDate,
                PolicyId            = riskModel.PolicyId,
                Id          = riskModel.Id,
                ValidTill   = validTill,
                YearlyPrice = riskModel.YearlyPrice
            };

            _riskRepository.Edit(updatedRiskModel);
        }
Ejemplo n.º 2
0
        public void InsuranceCompany_ShouldBeAbleToRemoveRiskFromExistingPolicy()
        {
            List <Risk> riskList = new List <Risk>();

            riskList.Add(Risk1);
            riskList.Add(Risk2);

            var effectiveDate    = DateTime.Now;
            var newValidTillDate = effectiveDate.AddMonths(1);

            Company.SellPolicy(DEFAULT_OBJECT_NAME, effectiveDate, 6, riskList);
            Company.RemoveRisk(DEFAULT_OBJECT_NAME, Risk2, newValidTillDate, effectiveDate);

            var riskId = IdGenerator.ConstructRiskId(Risk2.Name, DEFAULT_OBJECT_NAME, effectiveDate);

            var updatedRisk = RiskRepository.Get(riskId);

            Assert.AreEqual(newValidTillDate, updatedRisk.ValidTill);
        }