public async Task <List <Occupation> > Get() { var occupations = await _occupationRepository.Get(); return(occupations?.ConvertAll(occupation => new Occupation { Id = occupation.Id, Label = occupation.Label })); }
public async Task <Premium> Calculate(int age, int occupationId, double deathCoverAmount, double monthlyExpense) { var occupation = await _occupationRepository.Get(occupationId); if (occupation == null) { throw new Exception("Occupation not found."); // TODO: Throw specific business exception to be logged properly } return(new Premium { // TODO: Get this value from a monthly preminum strategy DeathPremium = (deathCoverAmount * occupation.Rating.Factor * age) / MONTHLY_PREMIUM_DENOMINATOR, // TODO: Get this value from yearly cover strategy YearlyCover = monthlyExpense * occupation.Rating.Factor * age }); }
public async Task CalculateTest_Returns_DeathPremium(DateTime dateOfBirth, int occupationId, double deathCoverAmount, double monthlyExpense) { // Arrange _occupationsRepository.Get(occupationId).Returns(Task.FromResult(new Data.Entities.Occupation { Id = 1, Label = "", Rating = new Data.Entities.Rating { Id = 1, Factor = 1.1 } })); // Act var result = await _premiumService.Calculate(dateOfBirth.Age(), occupationId, deathCoverAmount, monthlyExpense); // Assert result.ShouldNotBeNull(); result.DeathPremium.ShouldBeGreaterThan(0); result.YearlyCover.ShouldBeGreaterThan(0); }