Example #1
0
        public void CalculatePurchaseAmountWithDiscount_Should_Return_Correct_Sum(double purchaseAmount, double purchaseAmountWithDiscount)
        {
            // arrange
            IDiscountService discountService = new DiscountService();

            IReadOnlyCollection <DiscountSettings> settings = new List <DiscountSettings>()
            {
                new DiscountSettings()
                {
                    Percentage = 1, MinAmount = 1000, MaxAmount = 1999
                },
                new DiscountSettings()
                {
                    Percentage = 3, MinAmount = 2000, MaxAmount = 4999
                },
                new DiscountSettings()
                {
                    Percentage = 4, MinAmount = 5000, MaxAmount = 9999
                },
                new DiscountSettings()
                {
                    Percentage = 5, MinAmount = 10000, MaxAmount = null
                }
            };

            discountService.SetDiscountSettings(settings);
            var card = new DiscountCard();

            card.AddAmountForDiscount(purchaseAmount);

            // act
            double result = discountService.CalculatePurchaseAmountWithDiscount(card, purchaseAmount);

            // assert
            Assert.Equal(purchaseAmountWithDiscount, result);
        }