public void TestMethod_ForScenario3_ReturnsTotalPrice() { Dictionary <String, int> cart1 = new Dictionary <String, int>(); cart1.Add("itemA", 3); Dictionary <String, int> cart2 = new Dictionary <String, int>(); cart2.Add("itemB", 2); Dictionary <String, int> cart3 = new Dictionary <String, int>(); cart3.Add("itemC", 1); cart3.Add("itemD", 1); List <Promotion> promotions = new List <Promotion>() { new Promotion(1, cart1, 130), new Promotion(2, cart2, 45), new Promotion(3, cart3, 30) }; Order order = new Order(3, new List <Product>() { new Product("itemA"), new Product("itemA"), new Product("itemA"), new Product("itemB"), new Product("itemB"), new Product("itemB"), new Product("itemB"), new Product("itemB"), new Product("itemC"), new Product("itemD") }); decimal expectedvalue = 280; decimal promotionalPrices = promotions .Select(promo => CalculatePromotion.GetTotalPrice(order, promo)) .ToList().Sum(); Assert.IsNotNull(promotionalPrices); Assert.AreEqual(expectedvalue, promotionalPrices); }
public void TestScenarioD() { var cp = new CalculatePromotion(); var cart = CalculatePromotion.CreateCart(30, 50, 25, 20); var promo = PromotionOffers.CreatePromotion(); var totalprice = cp.GetOrderValue(cart, promo); Assert.AreEqual(totalprice, 3125); }
public void TestScenarioC() { var cp = new CalculatePromotion(); var cart = CalculatePromotion.CreateCart(3, 5, 1, 1); var promo = PromotionOffers.CreatePromotion(); var totalprice = cp.GetOrderValue(cart, promo); Assert.AreEqual(totalprice, 280); }
public void TestMethod5() { using (var sw = new StringWriter()) { Console.SetOut(sw); CalculatePromotion calculatePromotion = new CalculatePromotion(); calculatePromotion.ActivePromotionCalculation(3, 5, 9, 7); var result = sw.ToString(); NUnit.Framework.Assert.AreEqual("500", result); } }
public PromotionTests() { _promotions = new Promotions(); promotionCalculate = new CalculatePromotion(_promotions); }