public void CheckChange0Inserted() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Coin> <Type>0.5</Type> <Ammount>20</Ammount> </Coin> <Coin> <Type>1</Type> <Ammount>50</Ammount> </Coin> <Coin> <Type>2</Type> <Ammount>10</Ammount> </Coin> <Coin> <Type>5</Type> <Ammount>20</Ammount> </Coin> <Coin> <Type>10</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>20</Type> <Ammount>10</Ammount> </Coin> </Root>"; CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); bool result = coinMan.CheckChange(0, 0); Assert.IsTrue(result); }
public void AddCoin761() { CoinManager coinManager; coinManager = new CoinManager(); this.AddCoin(coinManager, Coin.Kr2, 2); Assert.IsNotNull((object)coinManager); }
public void AddCoin911() { CoinManager coinManager; coinManager = new CoinManager(); this.AddCoin(coinManager, Coin.Ore50, 1); Assert.IsNotNull((object)coinManager); }
public Form1() { InitializeComponent(); machine = new VendMachine(); prepareOutOfStockLights(); CoinManager coins = new CoinManager(); coins.EjectCoin(Coin.Ore50, 1, new LinkedList<Coin>()); }
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>(); }
// Scenario: Database is null // Expected outcome: Constructor throws exception public void ConstructorTest2() { string doc = null; try { CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); Assert.Fail(); } catch (Exception) { } }
public void EjectCoin502() { CoinManager coinManager; LinkedList<Coin> linkedList; LinkedList<Coin> linkedList1; coinManager = new CoinManager(); Coin[] @is = new Coin[0]; linkedList = new LinkedList<Coin>((IEnumerable<Coin>)@is); linkedList1 = new LinkedList<Coin>((IEnumerable<Coin>)linkedList); this.EjectCoin(coinManager, Coin.Ore50, 1, linkedList1); Assert.IsNotNull((object)coinManager); }
public void ConstructorTest() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> </Root>"; try { CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); Assert.Fail(); } catch (Exception) { } }
public void AddCoinThrowsContractException830() { try { CoinManager coinManager; coinManager = new CoinManager(); this.AddCoin(coinManager, Coin.Ore50, 0); throw new AssertFailedException("expected an exception of type ContractException"); } catch (Exception ex) { if (!PexContract.IsContractException(ex)) throw ex; } }
public void GetChangeCaseNull() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Coin> <Type>0.5</Type> <Ammount>10</Ammount> </Coin> <Coin> <Type>1</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>2</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>10</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>20</Type> <Ammount>1</Ammount> </Coin> </Root>"; CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); LinkedList<Coin> list = null; try { coinMan.GiveChange(5, 5, list); Assert.Fail(); } catch (Exception) { } }
public void EjectCoinCaseNotEmpty() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Coin> <Type>0.5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>1</Type> <Ammount>10</Ammount> </Coin> <Coin> <Type>2</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>10</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>20</Type> <Ammount>0</Ammount> </Coin> </Root>"; CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); LinkedList<Coin> linkedList = new LinkedList<Coin>(); linkedList.AddLast(Coin.Kr1); linkedList.AddLast(Coin.Kr1); coinMan.EjectCoin(Coin.Kr1, 2, linkedList); Assert.IsNotNull(coinMan); }
public void CheckChangeIncorrectPrice() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Coin> <Type>0.5</Type> <Ammount>20</Ammount> </Coin> <Coin> <Type>1</Type> <Ammount>50</Ammount> </Coin> <Coin> <Type>2</Type> <Ammount>10</Ammount> </Coin> <Coin> <Type>5</Type> <Ammount>20</Ammount> </Coin> <Coin> <Type>10</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>20</Type> <Ammount>10</Ammount> </Coin> </Root>"; CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); try { bool result = coinMan.CheckChange(-10, 9); Assert.Fail(); } catch (Exception) { } }
public void GetChangeCorrect() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Coin> <Type>0.5</Type> <Ammount>20</Ammount> </Coin> <Coin> <Type>1</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>2</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>10</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>20</Type> <Ammount>0</Ammount> </Coin> </Root>"; CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); LinkedList<Coin> list = new LinkedList<Coin>(); coinMan.GiveChange(10, 20,list); decimal sum=0; foreach (Coin elem in list) { sum += elem.ToValue(); } Assert.AreEqual(10, sum); }
public void EjectCoinThrowsContractException868() { try { CoinManager coinManager; coinManager = new CoinManager(); this.EjectCoin(coinManager, Coin.Ore50, 1, (LinkedList<Coin>)null); throw new AssertFailedException("expected an exception of type ContractException"); } catch (Exception ex) { if (!PexContract.IsContractException(ex)) throw ex; } }
public void CheckChangeNotEnoughSmallCoins() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Coin> <Type>0.5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>1</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>2</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>10</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>20</Type> <Ammount>1</Ammount> </Coin> </Root>"; CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); bool result = coinMan.CheckChange(1, 10); Assert.IsFalse(result); }
public void EjectCoinNotEnoughCoins() { string doc = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Root> <Coin> <Type>0.5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>1</Type> <Ammount>1</Ammount> </Coin> <Coin> <Type>2</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>5</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>10</Type> <Ammount>0</Ammount> </Coin> <Coin> <Type>20</Type> <Ammount>0</Ammount> </Coin> </Root>"; CoinManager coinMan = new CoinManager(XDocument.Parse(doc)); LinkedList<Coin> linkedList = new LinkedList<Coin>(); try { coinMan.EjectCoin(Coin.Kr1, 2, linkedList); Assert.Fail(); } catch (Exception) { } }