コード例 #1
0
        public async Task <double> CalculateMonthlyPremium(int age, double deathSumInsured, string occupation, CancellationToken cancellationToken)
        {
            var rating = _occupationRatingsRepository.GetOccupationRatingsByOccupation(occupation, cancellationToken);

            if (rating == null)
            {
                throw new NotFoundException(Common.Constants.ErrorCodes.OccupationNotFound);
            }

            var factor = _ratingFactorRepository.GetRatingFactorByRating(rating, cancellationToken);

            if (factor == null)
            {
                throw new NotFoundException(Common.Constants.ErrorCodes.RatingNotFound);
            }
            var monthlyPremium = PremiumCalculatorHelper.CalcalatePremium(deathSumInsured, factor.Value, age);

            return(await Task.FromResult(monthlyPremium));
        }
コード例 #2
0
        public void CalcalatePremium(double deathCoverAmount, double occupationRatingFactor, int age, double premium)
        {
            var result = PremiumCalculatorHelper.CalcalatePremium(deathCoverAmount, occupationRatingFactor, age);

            result.Should().Be(premium);
        }