static void Main(string[] args) { #region "Scenario A" Order scenarioA = new Order(1, new List <Product>() { new Product("A", 50.0), new Product("B", 30.0), new Product("C", 20.0) }); decimal finalPrice = PromotionBusinessRules.GetFinalPrice(scenarioA); #endregion #region "Scenario B" Order scenarioB = new Order(1, new List <Product>() { new Product("A", 50.0), new Product("A", 50.0), new Product("A", 50.0), new Product("A", 50.0), new Product("A", 50.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("C", 20.0) }); decimal finalPrice2 = PromotionBusinessRules.GetFinalPrice(scenarioB); #endregion #region "Scenario C" Order scenarioC = new Order(1, new List <Product>() { new Product("A", 50.0), new Product("A", 50.0), new Product("A", 50.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("C", 20.0), new Product("D", 15.0) }); decimal finalPrice3 = PromotionBusinessRules.GetFinalPrice(scenarioC); #endregion }
public void NoPromotionTest() { Order order = new Order(1, new List <Product>() { new Product("A", 50.0), new Product("B", 30.0) }); Assert.AreEqual(80, PromotionBusinessRules.GetFinalPrice(order)); }
public static decimal GetFinalPrice(Order order) { List <decimal> discountprices = PromotionBusinessRules.GetActivePromotions() .Select(promo => PromotionBusinessRules.GetDiscountPrice(order, promo)) .ToList(); decimal origprice = order.Products.Sum(x => x.UnitPrice); decimal discountPrice = discountprices.Sum(); return(origprice - discountPrice); }
public void ScenarioTwoTest() { Order order = new Order(1, new List <Product>() { new Product("A", 50.0), new Product("A", 50.0), new Product("A", 50.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("B", 30.0), new Product("C", 20.0), new Product("D", 15.0) }); Assert.AreEqual(280, PromotionBusinessRules.GetFinalPrice(order)); }