public void EjectProductListNull() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Product> <Name>coke</Name> <Price>10</Price> <Ammount>5</Ammount> </Product> <Product> <Name>faxe</Name> <Price>12</Price> <Ammount>10</Ammount> </Product> <Product> <Name>daim</Name> <Price>7</Price> <Ammount>1</Ammount> </Product> </Root>"; StockManager stockMan = new StockManager(XDocument.Parse(doc)); try { stockMan.EjectProduct(new Product("daim"), null); Assert.Fail(); } catch (Exception) { } }
public void AddProductDifferentPrice() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Product> <Name>coke</Name> <Price>10</Price> <Ammount>5</Ammount> </Product> <Product> <Name>faxe</Name> <Price>12</Price> <Ammount>10</Ammount> </Product> <Product> <Name>daim</Name> <Price>7</Price> <Ammount>1</Ammount> </Product> </Root>"; StockManager stockMan = new StockManager(XDocument.Parse(doc)); stockMan.AddProduct(new Product("faxe", 9, 1)); }
public void EjectProductCorrect() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Product> <Name>coke</Name> <Price>10</Price> <Ammount>5</Ammount> </Product> <Product> <Name>faxe</Name> <Price>12</Price> <Ammount>10</Ammount> </Product> <Product> <Name>daim</Name> <Price>7</Price> <Ammount>1</Ammount> </Product> </Root>"; StockManager stockMan = new StockManager(XDocument.Parse(doc)); LinkedList<Product> list = new LinkedList<Product>(); stockMan.EjectProduct(new Product("faxe"),list); }
public VendMachine(XDocument stockDoc, XDocument coinDoc) { state = State.Idle; StockMan = new StockManager(stockDoc); CoinMan = new CoinManager(coinDoc); SelectedProduct = null; InsertedValue = 0; CoinCase = new LinkedList<Coin>(); ProductCase = new LinkedList<Product>(); }
public VendMachine() { state = State.Idle; StockMan = new StockManager(); CoinMan = new CoinManager(); SelectedProduct = null; InsertedValue = 0; CoinCase = new LinkedList<Coin>(); ProductCase = new LinkedList<Product>(); }
public void CheckMissing() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Product> <Name>coke</Name> <Price>10</Price> <Ammount>5</Ammount> </Product> </Root>"; StockManager stockMan = new StockManager(XDocument.Parse(doc)); bool result = stockMan.CheckAvailability(new Product("nothing")); Assert.AreEqual(false, result); }
public void CheckNull() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Product> <Name>coke</Name> <Price>10</Price> <Ammount>5</Ammount> </Product> </Root>"; StockManager stockMan = new StockManager(XDocument.Parse(doc)); try { bool result = stockMan.CheckAvailability(null); Assert.Fail(); } catch (Exception) { } }
public void AddProductIncorrectAmountParameter() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Product> <Name>coke</Name> <Price>10</Price> <Ammount>5</Ammount> </Product> <Product> <Name>faxe</Name> <Price>12</Price> <Ammount>10</Ammount> </Product> <Product> <Name>daim</Name> <Price>7</Price> <Ammount>1</Ammount> </Product> </Root>"; StockManager stockMan = new StockManager(XDocument.Parse(doc)); try { stockMan.AddProduct(new Product("faxe", -9, 12)); Assert.Fail(); } catch (Exception) { } }