private static ResultData getGrossPayable(int age, int sumAssured) { Console.WriteLine("Age - " + age + " sumAssured - " + sumAssured); ResultData resultData = new ResultData(); AgeRangeProvider ageRangeProvider = new AgeRangeProvider(); IAgeRangeProvider iageRangeProvider = ageRangeProvider; Enums.AgeRange ageRange = iageRangeProvider.getAgeRange(age); if (ageRange == Enums.AgeRange.OutOfRange) { Console.WriteLine("Age not supported"); return(resultData); } IAgeRange ageRangeObj = AgeRangeFactory.Build(ageRange); decimal riskRate = ageRangeObj.getRiskRate(age, sumAssured); Console.WriteLine("RiskRate is : " + riskRate); if (riskRate != 0.0M) { resultData = getGrossPremiumForPositiveRiskRate(age, riskRate, sumAssured); } else { Console.WriteLine("Risk rate Not available"); } return(resultData); }
public void GetAgeRange_InputIs60_Return_AboveFifty() { expectedAgeRange = Enums.AgeRange.AboveFifty; actualAgeRange = ageRange.getAgeRange(60); Assert.AreEqual(expectedAgeRange, actualAgeRange); }
public void GetAgeRange_InputIs40_Return_ThirtyOneToFifty() { expectedAgeRange = Enums.AgeRange.ThirtyOneToFifty; actualAgeRange = ageRange.getAgeRange(40); Assert.AreEqual(expectedAgeRange, actualAgeRange); }
public void GetAgeRange_InputIs20_Return_LessThanOrEqualToThirty() { expectedAgeRange = Enums.AgeRange.LessThanOrEqualToThirty; actualAgeRange = ageRange.getAgeRange(20); Assert.AreEqual(expectedAgeRange, actualAgeRange); }
public void GetAgeRange_InputIsLessThan18_Return_OutOfRange() { expectedAgeRange = Enums.AgeRange.OutOfRange; actualAgeRange = ageRange.getAgeRange(10); Assert.AreEqual(expectedAgeRange, actualAgeRange); }
public static IAgeRange Build(Enums.AgeRange ageRange) { switch (ageRange) { case Enums.AgeRange.LessThanOrEqualToThirty: return(new AgeRangeLessThanOrEqualToThirty()); case Enums.AgeRange.ThirtyOneToFifty: return(new AgeRangeThirtyOneToFifty()); case Enums.AgeRange.AboveFifty: default: return(new AgeRangeAboveFifty()); } }
Enums.AgeRange IAgeRangeProvider.getAgeRange(int age) { Enums.AgeRange agerange = Enums.AgeRange.OutOfRange; if (age >= 18 && age <= 30) { agerange = Enums.AgeRange.LessThanOrEqualToThirty; } else if (age >= 31 && age <= 50) { agerange = Enums.AgeRange.ThirtyOneToFifty; } else if (age >= 50 && age <= 65) { agerange = Enums.AgeRange.AboveFifty; } return(agerange); }