Esempio n. 1
0
        public void CalculateGiftAidReturnCorrectGiftAid(decimal donationAmount, decimal expectedValue)
        {
            // Act
            var result = _giftAidService.Calculate(donationAmount);

            // Assert
            Assert.Equal(result, expectedValue);
        }
Esempio n. 2
0
        public ActionResult GetGiftAid([FromQuery] GiftAidRequest giftAidRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (giftAidRequest is null)
            {
                return(BadRequest("Invalid donation"));
            }

            var calculatedGiftAidAmount = _giftAidService.Calculate(giftAidRequest.Amount);

            var giftAidResponse = new GiftAidResponse
            {
                DonationAmount = giftAidRequest.Amount,
                GiftAidAmount  = calculatedGiftAidAmount
            };

            return(Ok(giftAidResponse));
        }