public void TestInit() { pBox = new ProductBox("products", 40, 20); // name, typs of products, capacity of each product pBox.AddProduct(water, 20); // product, count pBox.AddProduct(soda, 20); pBox.AddProduct(cola, 20); /// 100 x 1p, 50 x 5p, 50 x 10p sBox = new CoinBox(Machine.StoreCoinBox); sBox.AddCoins(one, 100); // coin, count sBox.AddCoins(five, 50); sBox.AddCoins(ten, 50); rBox = new CoinBox(Machine.ReceiveCoinBox); rBox.Clear(); machine = new TestMachine(pBox, rBox, sBox, TestMessenger.Default); machine.Start(); }
public void IsEmptyTest() { /// ProductBox ProductBox pBox = new ProductBox("temp product box", 40, 20); Assert.IsTrue(pBox.IsEmpty); string productName = Guid.NewGuid().ToString(); int productPrice = Guid.NewGuid().GetHashCode(); pBox.AddProduct(new Product(productName, productPrice), 0); Assert.IsTrue(pBox.IsEmpty); Assert.AreEqual(0, pBox[new Product(productName, productPrice)]); pBox.AddProduct(new Product(productName, productPrice), 10); Assert.IsFalse(pBox.IsEmpty); Assert.AreEqual(10, pBox[new Product(productName, productPrice)]); /// CoinBox CoinBox cBox = new CoinBox("temp coin box"); Assert.IsTrue(cBox.IsEmpty); cBox.AddCoins(new Coin(1), 0); Assert.IsTrue(cBox.IsEmpty); cBox.AddCoins(new Coin(2), 0); Assert.IsTrue(cBox.IsEmpty); cBox.AddCoins(new Coin(5), 0); Assert.IsTrue(cBox.IsEmpty); cBox.AddCoins(new Coin(1), 1); Assert.IsFalse(cBox.IsEmpty); cBox.Clear(); Assert.IsTrue(cBox.IsEmpty); }