public void WhenUserIsNotRegistered_NoDiscount()
        {
            var originalPrice = 100;
            var calculator    = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice).ShouldBe(100);
        }
Ejemplo n.º 2
0
        public void CalculateDiscount_ReturnsOriginalPrice_WhenUserNotRegistered()
        {
            var originalPrice = 100;
            var calculator    = new UserDiscountCalculator();

            var result = calculator.CalculateDiscount(originalPrice, user: null);

            result.ShouldBe(originalPrice);
        }
        public void IfGoldAccount_Discount_7_Percent()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Gold
            };
            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(93);
        }
        public void IfSilverAccount_Discount_FourPercent()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Silver
            };
            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(96);
        }
        public void IfBronzeAccount_Discount_2_percent()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Bronze
            };
            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(98);
        }
        public void IfPotatoAccount_NoDiscount()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Potato
            };
            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(100);
        }
        public void IfGoldUserIsRegisteredFor6Years_Apply12PercentDiscount()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Gold, YearsRegistered = 6
            };

            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(88);
        }
        public void IfBronzeUserIsRegisteredFor5Years_Apply7PercentDiscount()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Bronze, YearsRegistered = 5
            };

            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(93);
        }
        public void IfUserIsRegisteredFor2Years_Apply2Percent()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Potato, YearsRegistered = 2
            };

            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(98);
        }
        public void IfPotatoUserIsRegisteredFor6Years_No_Discount()
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Potato, YearsRegistered = 6
            };

            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(95);
        }
        public void IfBronzeUserRegisteredForNYearsUpTo5_ApplyBronzeAndNYearDiscount(int nYears)
        {
            var originalPrice = 100;
            var testUser      = new User {
                AccountType = AccountType.Bronze, YearsRegistered = nYears
            };
            var expectedPrice = 98 - nYears;

            var calculator = new UserDiscountCalculator();

            calculator.CalculateDiscount(originalPrice, testUser).ShouldBe(expectedPrice);
        }