public void CalculateRunnerGiftAidHandlesNullSupplement()
        {
            string  eventName = "Running";
            decimal amount    = 10;

            _Donor.Setup(a => a.CalculateGiftAid(amount)).Returns(2.5m);
            _Repository.Setup(a => a.GetEventByName(eventName)).Returns(new TestConsole.Models.GiftAidEvent()
            {
                Id = "1", EventName = eventName
            });
            Assert.AreEqual(_EventPromoterRunning.CalculateRunnerGiftAid(amount), 2.525);

            _Repository.Verify(a => a.GetEventByName(It.IsAny <string>()), Times.Once, "IRepository - GetEventByName not get called!");
            _Donor.Verify(a => a.CalculateGiftAid(It.IsAny <decimal>()), Times.Once, "IDonor - CalculateGiftAid not get called!");
        }
Exemplo n.º 2
0
        public static void EventPromoterAid()
        {
            Console.WriteLine("Please enter an event from the followings "
                              + Environment.NewLine +
                              "Running / Swimming / Other.");
            EventTypes events = (EventTypes)Enum.Parse(typeof(EventTypes), Console.ReadLine().ToLower(), true);

            Console.WriteLine("Please Enter donation amount:");
            string s = Console.ReadLine();

            decimal aid = 0;

            if (_DecimalHelper.IsDecimal(s))
            {
                decimal amount = _DecimalHelper.RoundTwoDecimalPlaces(_DecimalHelper.ConvertToDecimal(s));

                switch (events)
                {
                case EventTypes.running:
                    aid = _DecimalHelper.RoundTwoDecimalPlaces(_EventPromoterRunning.CalculateRunnerGiftAid(amount));
                    break;

                case EventTypes.swimming:
                    aid = _DecimalHelper.RoundTwoDecimalPlaces(_EventPromoterSwimming.CalculateSwimmerGiftAid(amount));
                    break;

                // Other events promoter could be treated as a donor as there would be no supplement applied to their donation,
                // though it has been implemented the same way as the other event promoters, in case there would be future similar concepts
                case EventTypes.other:
                    aid = _DecimalHelper.RoundTwoDecimalPlaces(_EventPromoterOther.CalculateOtherGiftAid(amount));
                    break;

                default:
                    break;
                }
                Console.WriteLine("Gift aid is: £" + aid.ToString());
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Number is not in a correct format. Please try again.");
                EventPromoterAid();
            }
        }