public void CalcStateTaxServiceNullValueCheck_NotNull() { Product product = new Product() { Type = ProductType.Bicycle, Quantity = 3, UnitPrice = 500.0M }; ICalcService calcService = new CalcService(product); ICalcService calcDiscountService = new PriceCalcDiscountDecorator(calcService); ICalcService calcStateTaxService = new PriceCalcStateTaxDecorator(State.UT.ToString(), calcDiscountService); Assert.IsNotNull(calcStateTaxService); }
public void CalcDiscountService_TotalPrice_10PercentDiscount_StateAL() { Product product = new Product() { Type = ProductType.Bicycle, Quantity = 10, UnitPrice = 1200.0M }; string stateCode = State.AL.ToString(); ICalcService calcService = new CalcService(product); ICalcService calcDiscountService = new PriceCalcDiscountDecorator(calcService); decimal totalPrice = calcDiscountService.CalculatePrice(); ICalcService calcStateTaxService = new PriceCalcStateTaxDecorator(stateCode, calcDiscountService); totalPrice = calcStateTaxService.CalculatePrice(); Assert.AreEqual(totalPrice, decimal.Parse("11232")); }
static void Main(string[] args) { string stateCode; Product product = new Product(); Console.WriteLine(string.Format("Enter no. of {0}:", ProductType.Bicycle)); product.Quantity = int.Parse(Console.ReadLine()); Console.WriteLine(string.Format("Enter Price/{0}:", ProductType.Bicycle)); product.UnitPrice = int.Parse(Console.ReadLine()); Console.WriteLine("Enter State Code:"); stateCode = Console.ReadLine(); ICalcService calcService = new CalcService(product); Console.WriteLine("---------------------"); //Total price after Discount ICalcService calcDiscountService = new PriceCalcDiscountDecorator(calcService); decimal totalPrice = calcDiscountService.CalculatePrice(); Console.WriteLine("Total Price after discount: " + totalPrice); //Total price after Discount and State Tax ICalcService calcStateTaxService = new PriceCalcStateTaxDecorator(stateCode, calcDiscountService); totalPrice = calcStateTaxService.CalculatePrice(); Console.WriteLine("Total Price after discount & Tax: " + totalPrice); Console.WriteLine("\nPress any key to Exit.."); Console.ReadLine(); }