public void TestSetPricing_WithoutPointOfSale() { var terminal = new Terminal(); Assert.Throws <NullProductException>(() => { terminal.SetPricing("A", (decimal)1.25); }); }
public void TestTestScanProduct_WithoutPointOfSale() { var terminal = new Terminal(); var codes = "ABCABA"; var codeList = codes.ToCharArray().ToList(); Assert.Throws <NullProductException>(() => { foreach (var code in codeList) { terminal.ScanProduct(code.ToString()); } }); }
public void Setup() { _pointOfSale = new POS(); _terminal = new Terminal(_pointOfSale); var productA = new ProductA(); var productB = new ProductB(); var productC = new ProductC(); var productD = new ProductD(); List <Product> products = new List <Product> { productA, productB, productC, productD }; foreach (var product in products) { Utils.DoSafe(() => { _pointOfSale.AddProduct(product); }); } Utils.DoSafe(() => { _terminal.SetPricing(productA.Code, (decimal)1.25d); }); Utils.DoSafe(() => { _terminal.SetPricing(productA.Code, (decimal)3.00d, 3); }); Utils.DoSafe(() => { _terminal.SetPricing(productB.Code, (decimal)4.25d); }); Utils.DoSafe(() => { _terminal.SetPricing(productC.Code, (decimal)1.00d); }); Utils.DoSafe(() => { _terminal.SetPricing(productC.Code, (decimal)5.00d, 6); }); }
static void Main(string[] args) { Console.WriteLine("### Point Of Sale Terminal Service UP ###"); var terminal = new PointOfSaleTerminal(); // Set default pricing for Products Utils.SetDefaultPricing(terminal); // Order 1 terminal.ScanProduct("A"); terminal.ScanProduct("B"); terminal.ScanProduct("C"); terminal.ScanProduct("D"); terminal.ScanProduct("A"); terminal.ScanProduct("B"); terminal.ScanProduct("A"); Console.WriteLine($"Amount of Order 'ABCDABA': ${terminal.CalculateTotal()}"); //Prepare for next order terminal.ClearForNewOrder(); // Order 2 terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); Console.WriteLine($"Amount of Order 'CCCCCCC': ${terminal.CalculateTotal()}"); //Prepare for next order terminal.ClearForNewOrder(); // Order 3 terminal.ScanProduct("A"); terminal.ScanProduct("B"); terminal.ScanProduct("C"); terminal.ScanProduct("D"); Console.WriteLine($"Amount of Order 'ABCD': ${terminal.CalculateTotal()}"); }
public void Setup() { _pointOfSale = new POS(); _terminal = new Terminal(_pointOfSale); var productA = new ProductA(); var productB = new ProductB(); var productC = new ProductC(); var productD = new ProductD(); List <Product> products = new List <Product> { productA, productB, productC, productD }; foreach (var product in products) { Utils.DoSafe(() => { _pointOfSale.AddProduct(product); }); } }