public void BuySomeDrinksBeforeGetChange() { Init(); { Drink1.CostPrice = 2; Drink1.Count = 3; } { Drink2.CostPrice = 3; Drink2.Count = 5; } { } VengineMachine.AddCoin(Coin2, CurrentState); VengineMachine.AddCoin(Coin2, CurrentState); VengineMachine.BuyDrink(Drink1, CurrentState, CoinEntitiesList); Assert.AreEqual(2, CurrentState.Change); VengineMachine.AddCoin(Coin2, CurrentState); VengineMachine.AddCoin(Coin1, CurrentState); VengineMachine.AddCoin(Coin1, CurrentState); VengineMachine.BuyDrink(Drink2, CurrentState, CoinEntitiesList); Assert.AreEqual(3, CurrentState.Change); Assert.AreEqual(2, Drink1.Count); Assert.AreEqual(4, Drink2.Count); }
public void AddThreeCoin() { Init(); VengineMachine.AddCoin(Coin1, CurrentState); VengineMachine.AddCoin(Coin1, CurrentState); VengineMachine.AddCoin(Coin2, CurrentState); Assert.AreEqual(12, Coin1.Count); Assert.AreEqual(11, Coin2.Count); Assert.AreEqual(4, CurrentState.Deposit); }
public void CantBuyIfCountEqualsZero() { Init(); Drink1.CostPrice = 10; Drink1.Count = 0; Coin1.Count = 10; Coin1.Value = ValueCoins.Ten; VengineMachine.AddCoin(Coin1, CurrentState); Assert.IsFalse(VengineMachine.IsCanBuy(Drink1, CurrentState)); }
public int AddCoin(Guid id) { CoinEntity coinEntity = _coinRepository.Get(id); CurrentStateEntity currentState = _stateRepository.GetFirst(); _logger.Info(" before add coin"); _printer.CoinAndStateInfo(coinEntity, currentState); _vengineMachine.AddCoin(coinEntity, currentState); _logger.Info(" after add coin"); _printer.CoinAndStateInfo(coinEntity, currentState); _logger.Info(" before _db.SaveChanges()..."); _coinRepository.SaveChanges(); return(currentState.Deposit); }
public void CantBuyIfDepositLowerThanCost() { Init(); Drink1.CostPrice = 10; Drink1.Count = 1; Coin2.Count = 10; Coin2.Value = ValueCoins.Two; VengineMachine.AddCoin(Coin2, CurrentState); Assert.IsFalse(VengineMachine.IsCanBuy(Drink1, CurrentState)); Coin1.Count = 10; Coin1.Value = ValueCoins.Ten; VengineMachine.AddCoin(Coin1, CurrentState); Assert.IsTrue(VengineMachine.IsCanBuy(Drink1, CurrentState)); }