public VendingMachine() { this._rack = new CommodityRack(); this._coinMech = new CoinMech(); this._controller = new Controller(_coinMech, _rack); this.CommodityTray = new List<Juice>(); }
public void GetPurchasableListが購入可能な商品のリストを返す() { Controller ctl = new Controller(new CoinMech(), new CommodityRack()); ctl._rack.AddStock(Juice.RedBull, 5); ctl._rack.AddStock(Juice.Water, 5); //この時点で3種類の在庫が全て5個になる ctl._coinMech.InsertMoneyHelper(100, 10, 10); //120円だとレッドブル以外が買える CollectionAssert.AreEquivalent( new List<Juice>() { Juice.Cola, Juice.Water }, ctl.GetPurchasableList() ); }
public void 購入可能な場合はPurchaseがJuiceオブジェクトを返し預り金と売上金が変化する() { Controller ctl = new Controller(new CoinMech(), new CommodityRack()); ctl._coinMech.InsertMoneyHelper(100, 10, 10, 10); //130円投入したので10円戻るはず Assert.AreEqual(Juice.Cola, ctl.Purchase(Juice.Cola)); Assert.AreEqual(10, ctl._coinMech.Deposit); Assert.AreEqual(120, ctl._coinMech.Proceeds); Assert.AreEqual(10, ctl._coinMech.Payback()); //確認(ステップ3-5) }
public void 購入不可の場合はPurchaseがnullを返す() { Controller ctl = new Controller(new CoinMech(), new CommodityRack()); // お金を投入していないため購入不可 Assert.IsNull(ctl.Purchase(Juice.Cola)); }
public void 投入金額が足りている場合には購入可能だが在庫不足の場合には購入不可() { Controller ctl = new Controller(new CoinMech(), new CommodityRack()); for (int i = 0; i < 5; i++) { ctl._rack.Supply(Juice.Cola); } //ctl._coinMech.insertMoney(100); //ctl._coinMech.insertMoney(10); //ctl._coinMech.insertMoney(10); ctl._coinMech.InsertMoneyHelper(100, 10, 10); Assert.AreEqual(false,ctl.IsPurchasable(Juice.Cola)); }
public void 投入金額が不足している場合は購入不可() { Controller ctl = new Controller(new CoinMech(), new CommodityRack()); ctl._coinMech.InsertMoney(100); //コーラは120円なので買えない Assert.IsFalse(ctl.IsPurchasable(Juice.Cola)); }