public void ShouldDiscountFixedAmount() { long price = 1000; flatRateDiscountStratigy = new FlatRateDiscountStratigy(price); long discount = flatRateDiscountStratigy.Discount(); Assert.Equal(700, discount); }
public IDiscountStrategy CreateDiscountStratigy(int couponCode, long productPrice) { IDiscountStrategy stratigy; switch (couponCode) { case (int)CouponCodes.FlatRateCode: stratigy = new FlatRateDiscountStratigy(productPrice); break; case (int)CouponCodes.PercentageCode: stratigy = new PercentageDiscountStrategy(productPrice); break; case (int)CouponCodes.PercentageLimitCode: stratigy = new PercentageLimitDiscountStrategy(productPrice); break; default: throw new ApplicationException($"Sorry! {couponCode} is not a valid Coupon code."); } return(stratigy); }