public void CalledGetWithNullAmount()
        {
            var result = _controller.Get(null);

            var badRequestResult = result as BadRequestResult;

            Assert.IsNotNull(badRequestResult);
            _calculator.DidNotReceive();
        }
Beispiel #2
0
        public void CalculeGiftAidAmount()
        {
            IGiftAidRepository aidRepository = new GiftAidRepository(_dbContext);
            GiftAidController  controller    = new GiftAidController(aidRepository, _calculationService, _declarationService);

            double donationAmount = 150;
            var    expected       = 1.875;

            var actionResult = controller.Get(donationAmount);
            var okResult     = actionResult as OkObjectResult;
            var actual       = (GiftAidResponse)okResult.Value;

            Assert.IsType <GiftAidResponse>(actual);
            Assert.Equal(expected, actual.GiftAidAmount);
        }
        public void Get_ValidAmount_ReturnsGiftAidAmount()
        {
            var request = new CalculateGiftAidRequest
            {
                Amount = 100m
            };

            _giftAidCalculator.Calculate(request.Amount).Returns(20);
            _controller = new GiftAidController(_giftAidCalculator, _giftAidRepository, _postCodeValidator);

            var response        = _controller.Get(request) as JsonResult;
            var giftAidResponse = response.Value as CalculateGiftAidResponse;

            _giftAidCalculator.Received(1).Calculate(request.Amount);

            Assert.That(giftAidResponse.GiftAidAmount, Is.EqualTo(20));
        }