public void GivenPremiumCalculator_Revisited_Again_Before_WhenCalculatePremiumOnAboveRiskAgeLowerBoundarySmokerBikeOwner_ReturnsAmmountWithVeryHighRiskInsuranceMultiplier() { var policyHolderInfo = new PolicyHolderInfo { Age = 35, IsSmoker = true, OwnsMotorcycle = true }; var premiumCalculator = new PremiumCalculator_Revisited_Again_Before(); var result = premiumCalculator.CalculatePremium(policyHolderInfo, 10000); Assert.AreEqual(20000, result); }
public void GivenPremiumCalculator_Revisited_Again_After_WhenIsVeryHighRisk_ReturnsTrueForHighRiskPolicyHolders() { var policyHolderInfo = new PolicyHolderInfo { Age = 35, IsSmoker = true, OwnsMotorcycle = true }; var premiumCalculator = new PremiumCalculator_Revisited_Again_After(); var result = premiumCalculator.IsVeryHighRisk(policyHolderInfo); Assert.IsTrue(result); }
public decimal CalculatePremium(PolicyHolderInfo policyHolderInfo, decimal insuranceSum) { if (policyHolderInfo.Age > RiskAgeLowerBoundary && policyHolderInfo.IsSmoker && policyHolderInfo.OwnsMotorcycle) { return(insuranceSum * VeryHighRiskInsuranceMultiplier); } else if (policyHolderInfo.Age > RiskAgeLowerBoundary && policyHolderInfo.IsSmoker && !policyHolderInfo.OwnsMotorcycle) { return(insuranceSum * HighRiskInsuranceMultiplier); } else if (policyHolderInfo.Age > RiskAgeLowerBoundary && !policyHolderInfo.IsSmoker && policyHolderInfo.OwnsMotorcycle) { return(insuranceSum * MediumRiskInsuranceMultiplier); } else if (policyHolderInfo.Age > RiskAgeLowerBoundary && !policyHolderInfo.IsSmoker && !policyHolderInfo.OwnsMotorcycle) { return(insuranceSum * LowRiskInsuranceMultiplier); } else { return(insuranceSum); } }
public decimal CalculatePremium(PolicyHolderInfo policyHolderInfo, decimal insuranceSum) { if (IsVeryHighRisk(policyHolderInfo)) { return(insuranceSum * VeryHighRiskInsuranceMultiplier); } else if (IsHighRisk(policyHolderInfo)) { return(insuranceSum * HighRiskInsuranceMultiplier); } else if (IsMediumRisk(policyHolderInfo)) { return(insuranceSum * MediumRiskInsuranceMultiplier); } else if (IsLowRisk(policyHolderInfo)) { return(insuranceSum * LowRiskInsuranceMultiplier); } else // IsNoRisk { return(insuranceSum); } }
public virtual bool IsLowRisk(PolicyHolderInfo policyHolderInfo) { return(policyHolderInfo.Age > RiskAgeLowerBoundary && !policyHolderInfo.IsSmoker && !policyHolderInfo.OwnsMotorcycle); }