Exemplo n.º 1
0
 public void Less_or_equal_than_zero_donation_amount_should_throw_exception()
 {
     var           taxRepository     = new Mock <ITaxRepository>();
     var           giftAidCalculator = new Model.GiftAidCalculator(taxRepository.Object);
     const decimal donationAmount    = -10.0m;
     var           otherEvent        = _events.Find(e => e.EventType == EventType.Other);
     var           giftAidAmount     = giftAidCalculator.CalculateGiftAidAmount(donationAmount, otherEvent);
 }
Exemplo n.º 2
0
        private static void CalculateGiftAid(TaxRepository taxRepository, EventSupplement selectedEventSupplement)
        {
            Console.WriteLine("Please Enter donation amount:");
            var donation = decimal.Parse(Console.ReadLine());

            var giftAidCalculator = new Model.GiftAidCalculator(taxRepository);

            Console.WriteLine("Your gift aid amount is:");
            Console.WriteLine(giftAidCalculator.CalculateGiftAidAmount(donation, selectedEventSupplement));
        }
Exemplo n.º 3
0
        public void Gift_aid_should_return_proper_amount_with_three_percent_supplement_on_swimming_events()
        {
            var taxRepository = new Mock <ITaxRepository>();

            taxRepository.Setup(t => t.RetrieveTaxRate()).Returns(20m);
            var           giftAidCalculator = new Model.GiftAidCalculator(taxRepository.Object);
            const decimal donationAmount    = 100m;
            var           swimmingEvent     = _events.Find(e => e.EventType == EventType.Swimming);
            var           giftAidAmount     = giftAidCalculator.CalculateGiftAidAmount(donationAmount, swimmingEvent);

            Assert.AreEqual(25.75m, giftAidAmount);
        }
Exemplo n.º 4
0
        public void Gift_aid_should_return_proper_amount_with_correct_tax()
        {
            var taxRepository = new Mock <ITaxRepository>();

            taxRepository.Setup(t => t.RetrieveTaxRate()).Returns(20m);
            var           giftAidCalculator = new Model.GiftAidCalculator(taxRepository.Object);
            const decimal donationAmount    = 4.0m;
            var           otherEvent        = _events.Find(e => e.EventType == EventType.Other);
            var           giftAidAmount     = giftAidCalculator.CalculateGiftAidAmount(donationAmount, otherEvent);

            Assert.AreEqual(1.0m, giftAidAmount);
        }
Exemplo n.º 5
0
        public void Gift_aid_amount_should_be_rounded_to_two_decimal_digits()
        {
            var taxRepository = new Mock <ITaxRepository>();

            taxRepository.Setup(t => t.RetrieveTaxRate()).Returns(17.5m);
            var           giftAidCalculator = new Model.GiftAidCalculator(taxRepository.Object);
            const decimal donationAmount    = 55.5m;
            var           otherEvent        = _events.Find(e => e.EventType == EventType.Other);
            var           giftAidAmount     = giftAidCalculator.CalculateGiftAidAmount(donationAmount, otherEvent);

            const decimal expectedValue = 11.77m;

            //Assert
            Assert.AreEqual(giftAidAmount, expectedValue);
        }