public void GivenDonationAmount_GiftAidIsCalculated_AtDefaultTwentyPercent(int donationAmount, float expectedGiftAid)
        {
            // Act
            var calculatedGiftAid = _giftAidCalculationService.CalculateGiftAid(donationAmount);

            // Assert
            Assert.Equal(expectedGiftAid, calculatedGiftAid);
        }
示例#2
0
        public ActionResult <CalculateGiftAidResponse> Calculate([Required][Range(2, 100000, ErrorMessage = "Donation amount has to be withing 2 to 100000")] int donationAmount)
        {
            try
            {
                var giftAidAmount = _giftAidCalculationService.CalculateGiftAid(donationAmount);

                var response = new CalculateGiftAidResponse
                {
                    DonationAmount = donationAmount,
                    GiftAidAmount  = giftAidAmount
                };

                return(response);
            }
            catch (Exception ex)
            {
                Log.Debug(ex.Message + Environment.NewLine + ex.StackTrace);

                return(StatusCode((int)HttpStatusCode.InternalServerError, "Failed to calculate gift aid"));
            }
        }