Esempio n. 1
0
        public void SelectNonExistentProductFail()
        {
            var readyToSellState = CreateReadyToSellProductState();

            readyToSellState.SelectProduct(Product.Espresso);

            var state = new ReadyToAcceptCoins(readyToSellState);

            Assert.Throws <NotSufficientAmountException>(
                () => state.InsertCoins(new List <Coin> {
                Coin.HalfEuro
            })
                );

            Assert.True(state.VendingMachine.State is ReadyToAcceptCoins);
        }
Esempio n. 2
0
        public void InsertCoinsAndChangeStateSuccess()
        {
            var state = new ReadyToAcceptCoins(CreateReadyToSellProductState());

            state.InsertCoins(new List <Coin>
            {
                Coin.HalfEuro,
                Coin.OneEuro
            }
                              );

            var insertedCoins = state.InsertedCoins.ToList();

            Assert.True(insertedCoins.Count == 2);
            Assert.Equal(Coin.HalfEuro, insertedCoins[0]);
            Assert.Equal(Coin.OneEuro, insertedCoins[1]);

            Assert.True(state.VendingMachine.State is ReadyToProcessOrder);
        }