예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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);
        }
예제 #5
0
        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));
        }