public void TestScanMultipleItems() { ItemRule ruleForA = new ItemRule('A', 50); CheckOut checkout = new CheckOut(new List<IRule>() { ruleForA }); checkout.Scan('A'); checkout.Scan('A'); Assert.AreEqual(100, checkout.Total); }
public void CreateRules() { IRule ruleForA = new ItemRule('A', 50); IRule ruleForB = new ItemRule('B', 30); IRule ruleForC = new ItemRule('C', 20); IRule ruleForD = new ItemRule('D', 15); IRule ruleForThreeA = new MultipriceItemRule('A', 3, 130); IRule ruleForTwoB = new MultipriceItemRule('B', 2, 45); rules = new List<IRule>() { ruleForA, ruleForB, ruleForC, ruleForD, ruleForThreeA, ruleForTwoB }; }
public void TestScanDifferentlyPricedItems() { ItemRule ruleForA = new ItemRule('A', 50); ItemRule ruleForB = new ItemRule('B', 30); List<IRule> myRules = new List<IRule>() { ruleForA, ruleForB }; CheckOut checkout = new CheckOut(myRules); checkout.Scan('A'); checkout.Scan('B'); Assert.AreEqual(80, checkout.Total); }
public void TestScanMultipleItemsMultiPriced() { IRule ruleForA = new ItemRule('A', 50); IRule ruleForThreeA = new MultipriceItemRule('A', 3, 130); IRule ruleForB = new ItemRule('B', 30); IRule ruleForTwoB = new MultipriceItemRule('B', 2, 45); List<IRule> myRules = new List<IRule>() { ruleForA, ruleForThreeA, ruleForB, ruleForTwoB }; CheckOut checkout = new CheckOut(myRules); checkout.Scan('A'); checkout.Scan('B'); Assert.AreEqual(80, checkout.Total); checkout.Scan('A'); checkout.Scan('A'); Assert.AreEqual(160, checkout.Total); checkout.Scan('B'); Assert.AreEqual(175, checkout.Total); checkout.Scan('B'); Assert.AreEqual(205, checkout.Total); checkout.Scan('A'); Assert.AreEqual(255, checkout.Total); }
public void TestScanMultipricedItem() { IRule ruleForA = new ItemRule('A', 50); IRule ruleForThreeA = new MultipriceItemRule('A', 3, 130); List<IRule> myRules = new List<IRule>() { ruleForA, ruleForThreeA }; CheckOut checkout = new CheckOut(myRules); checkout.Scan('A'); checkout.Scan('A'); Assert.AreEqual(100, checkout.Total); checkout.Scan('A'); Assert.AreEqual(130, checkout.Total); }