public void Discount15ShouldDecreasePriceAfterTax() { Product product = Product.Sample; Discount discount = new Discount(15); AffectPriceResult result = discount.ApplyTo(product.Price); string expected = "Discount: rate = 15%, amount = $3.04. Price: before = $20.25, after = $17.21"; Assert.AreEqual(expected, result.DescribeWith(product, discount)); }
public void NoneDiscountShouldNotAffectPrice() { Product product = Product.Sample; Discount discount = Discount.None; AffectPriceResult result = discount.ApplyTo(product.Price); string expected = "Discount: rate = 0%, amount = $0.00. Price: before = $20.25, after = $20.25"; Assert.AreEqual(expected, result.DescribeWith(product, discount)); }
public void Tax20Discount15ShouldAffectPriceAfterTax() { Product product = Product.Sample; Tax tax = new Tax(20); AffectPriceResult taxResult = tax.ApplyTo(product.Price); Discount discount = new Discount(15); AffectPriceResult discountResult = discount.ApplyTo(product.Price); Amount priceAfterAll = product.Price + taxResult.AffectedAmount - discountResult.AffectedAmount; Assert.AreEqual("20%", tax.ToString()); Assert.AreEqual("$4.05", taxResult.AffectedAmount.ToString()); Assert.AreEqual("15%", discount.ToString()); Assert.AreEqual("$3.04", discountResult.AffectedAmount.ToString()); Assert.AreEqual("$21.26", priceAfterAll.ToString()); }