コード例 #1
0
ファイル: Order.cs プロジェクト: VickyHuang5/DPHomework
        /// <summary>
        /// 計算折扣
        /// </summary>
        /// <param name="discount">折扣</param>
        /// <returns>折扣後金額</returns>
        public int CalculateDiscount(IDiscount discount)
        {
            int checkoutAmount = this.OriginalPrice;

            checkoutAmount = this.OriginalPrice - discount.CalculateDiscountAmount(this.OriginalPrice);
            return(checkoutAmount);
        }
コード例 #2
0
        public void Caclulate_Discount_No_Special_Offers_To_Be_Applied_Returns_Zero()
        {
            // Arrange
            var items = new List <Item>
            {
                new Item
                {
                    SKU   = "A99",
                    Price = 0.50m
                },
                new Item
                {
                    SKU   = "B15",
                    Price = 0.30m
                },
                new Item
                {
                    SKU   = "C40",
                    Price = 0.60m
                }
            };

            // Act
            var discount = _discount.CalculateDiscountAmount(items);

            // Assert
            Assert.AreEqual(0, discount);
        }
コード例 #3
0
ファイル: Checkout.cs プロジェクト: Banksy93/CheckoutKata
        public decimal Total()
        {
            if (!_items.Any())
            {
                return(0);
            }

            var total = _items.Sum(item => item.Price);

            var discountAmount = _discount.CalculateDiscountAmount(_items);

            return(total - discountAmount);
        }