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); }); }
public void TestSetPricing_WithoutPointOfSale() { var terminal = new Terminal(); Assert.Throws <NullProductException>(() => { terminal.SetPricing("A", (decimal)1.25); }); }
public void TestSetPricing_UnavailableProduct(string productCode, decimal price) { Assert.Throws <NullProductException>(() => { _terminal.SetPricing(productCode, price); }); }