コード例 #1
0
        public void CanMakeTenPercentDiscountOnPepsi()
        {
            // arrange
            var pepsiTenPercentOff = new PercentDiscount {PercentOff = 10m, Product = Pepsi};
            _order.AddDiscount(pepsiTenPercentOff);
            _order.ApplyDiscounts();

            // act
            var total = _order.CalculateTotal();

            // assert
            Assert.Equal(0.9m, total);
        }
コード例 #2
0
        public void UnableToApplySameDiscountsTwice()
        {
            // arrange
            var pepsiTenPercentOff = new PercentDiscount { PercentOff = 10m, Product = Pepsi };
            _order.AddDiscount(pepsiTenPercentOff);

            // act
            _order.ApplyDiscounts();
            _order.ApplyDiscounts();

            // assert
            var total = _order.CalculateTotal();
            Assert.Equal(0.9m, total);
        }