static void Main(string[] args) { while (true) { PromotionEngine.PromoGenerator(); } }
public void Scenario2_ApplyPromotion_ReturnTotal() { //Prepare Cart cart = new Cart() { CartSKUs = new List <CartSKU>() { new CartSKU() { Id = "A", Quantity = 5 }, new CartSKU() { Id = "B", Quantity = 5 }, new CartSKU() { Id = "C", Quantity = 1 }, } }; //Act IPromotionEngine promotionEngine = new PromotionEngine.PromotionEngine(priceList, new PromotionStrategy()); double result = promotionEngine.ApplyPromotion(cart); //Assert Assert.AreEqual(370, result); }
static void Main(string[] args) { PromotionEngine obj = new PromotionEngine(); Console.WriteLine("*** Welcome to Promotion Enging ***"); //Select to test the scenarios as mentioned in PDF. Console.WriteLine("1. To execute existing test scenarios."); //Select to test a dynamic scenario in real time. Console.WriteLine("2. To test a new Scenario."); try { int selectedValue = Convert.ToInt32(Console.ReadLine()); //Switch Case using C# 8 var res = selectedValue switch { 1 => obj.testExistingScenarios(), 2 => obj.testnewScenarioCartOrder(), _ => "Invalid Selection", }; Console.WriteLine(res); } catch (FormatException) { Console.WriteLine("Select/Enter a positive integer value"); } catch (Exception) { throw; } Console.ReadLine(); }
static void Main(string[] args) { IPromotionEngine <List <char> > promotionEngine = new PromotionEngine(); ICartEngine <List <char> > cartEngine = new CartEngine(); Billing billing = new Billing(promotionEngine, cartEngine); //// Test Setup 1 List <char> testScenario1 = new List <char>(); testScenario1.Add('A'); testScenario1.Add('B'); testScenario1.Add('C'); int totalAmount = billing.CalculateTotalPrice(testScenario1); }
public void Promotion_Is_Not_Applied_When_Products_Has_Invalid_CartItem() { int expected = 0; IPromotionEngine <List <char> > promotionEngine = new PromotionEngine.PromotionEngine(); ICartEngine <List <char> > cartEngine = new CartEngine(); Billing billing = new Billing(promotionEngine, cartEngine); List <char> orderedProducts = new List <char> { 'Z' }; int actual = billing.CalculateTotalPrice(orderedProducts); Assert.AreEqual(expected, actual); }
public void Promotion_Is_Not_Applied_On_Products() { int expected = 100; IPromotionEngine <List <char> > promotionEngine = new PromotionEngine.PromotionEngine(); ICartEngine <List <char> > cartEngine = new CartEngine(); Billing billing = new Billing(promotionEngine, cartEngine); List <char> orderedProducts = new List <char> { 'A', 'B', 'C' }; int actual = billing.CalculateTotalPrice(orderedProducts); Assert.AreEqual(expected, actual); }
static void Main(string[] args) { //Scenario A IList <OrderLine> orderLines = PromotionEngine.GetOrderLines("A"); PromotionEngine scenarioA = new PromotionEngine(orderLines); Console.WriteLine($"Scenario A - Total : {scenarioA.Calculate()}"); //Scenario B orderLines = PromotionEngine.GetOrderLines("B"); PromotionEngine scenarioB = new PromotionEngine(orderLines); Console.WriteLine($"Scenario B - Total : {scenarioB.Calculate()}"); //Scenario C orderLines = PromotionEngine.GetOrderLines("C"); PromotionEngine scenarioC = new PromotionEngine(orderLines); Console.WriteLine($"Scenario C - Total : {scenarioC.Calculate()}"); Console.ReadLine(); }
public void Promotion1_only_Applied_On_Products_Eventhough_Multiple_Promotions_Are_Valid() { int expected = 195; IPromotionEngine <List <char> > promotionEngine = new PromotionEngine.PromotionEngine(); ICartEngine <List <char> > cartEngine = new CartEngine(); Billing billing = new Billing(promotionEngine, cartEngine); List <char> orderedProducts = new List <char> { 'A', 'A', 'A', 'B', 'C', 'D' }; int actual = billing.CalculateTotalPrice(orderedProducts); Assert.AreEqual(expected, actual); }