Esempio n. 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);
        }
Esempio n. 2
0
        public void DrinkChangeImage()
        {
            Init();

            VengineMachine.ChangeImage(Drink1, "filename1");
            Assert.AreEqual("filename1", Drink1.ImagePath);
        }
Esempio n. 3
0
        public void DrinkChangeCount()
        {
            Init();

            VengineMachine.ChangeCount(Drink1, 8);
            Assert.AreEqual(8, Drink1.Count);
        }
Esempio n. 4
0
        public void ChangeCoinCount()
        {
            Init();

            VengineMachine.ChangeCoinCount(Coin1, 20);

            Assert.AreEqual(20, Coin1.Count);
        }
Esempio n. 5
0
 public void GetChange()
 {
     Init();
     CurrentState.Change = 5;
     VengineMachine.GetChange(CurrentState, CoinEntitiesList);
     Assert.AreEqual(9, Coin1.Count);
     Assert.AreEqual(8, Coin2.Count);
 }
Esempio n. 6
0
        public void BuyDrink()
        {
            Init();

            CurrentState.Deposit = 15;
            VengineMachine.BuyDrink(Drink1, CurrentState, CoinEntitiesList);
            Assert.AreEqual(1, Drink1.Count);
            Assert.AreEqual(5, CurrentState.Change);
        }
Esempio n. 7
0
        public void DrinkChangeCost()
        {
            Init();

            DrinkEntity drink1 = DrinkEntitiesList[0];

            VengineMachine.ChangeCost(drink1, 50);

            Assert.AreEqual(50, drink1.CostPrice);
        }
Esempio n. 8
0
        public void BlockUnblock()
        {
            Init();

            VengineMachine.Block(Coin1);
            VengineMachine.UnBlock(Coin2);

            Assert.IsTrue(Coin1.IsBlocking);
            Assert.IsFalse(Coin2.IsBlocking);
        }
Esempio n. 9
0
        /*protected FakeRepository<DrinkEntity> RepositoryDrink;*/

        public virtual void Init()
        {
            Drink1 = new DrinkEntity()
            {
                CostPrice = 10,
                Count     = 2,
                Id        = Guid.Parse("FFDF9A9C-1FC1-4DEB-B552-45EB5E0EC48C"),
                ImagePath = "image1",
                Name      = "drink1"
            };

            Drink2 = new DrinkEntity()
            {
                CostPrice = 20,
                Count     = 4,
                Id        = Guid.NewGuid(),
                ImagePath = "image2",
                Name      = "drink2"
            };

            Coin1 = new CoinEntity()
            {
                Id         = Guid.NewGuid(),
                Count      = 10,
                IsBlocking = false,
                Value      = ValueCoins.One
            };

            Coin2 = new CoinEntity()
            {
                Id         = Guid.NewGuid(),
                Count      = 10,
                IsBlocking = true,
                Value      = ValueCoins.Two
            };

            CurrentState = new CurrentStateEntity()
            {
                Change  = 0,
                Deposit = 0
            };

            DrinkEntitiesList = new List <DrinkEntity> {
                Drink1, Drink2
            };
            CoinEntitiesList = new List <CoinEntity> {
                Coin1, Coin2
            };

            /*RepositoryDrink = new FakeRepository<DrinkEntity>(DrinkEntitiesList);
             * var repositoryCoin = new FakeRepository<CoinEntity>(CoinEntitiesList);*/

            VengineMachine = new VengineMachine(/*RepositoryDrink, repositoryCoin*/);
        }
Esempio n. 10
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);
        }
 public UserService(IRepository <CoinEntity> coinRepository,
                    IRepository <DrinkEntity> drinkRepository,
                    ISimpleRepo <CurrentStateEntity> stateRepository,
                    IVendingMachineLogger logger)
 {
     _coinRepository  = coinRepository;
     _drinkRepository = drinkRepository;
     _stateRepository = stateRepository;
     _logger          = logger;
     _vengineMachine  = new VengineMachine();
     _printer         = new Printer(logger);
 }
        public AdminService(IRepository <CoinEntity> coinRepository,
                            IRepository <DrinkEntity> drinkRepository,
                            IVendingMachineLogger logger, IStrategy strategyImport)
        {
            _coinRepository  = coinRepository;
            _drinkRepository = drinkRepository;
            _logger          = logger;


            _vengineMachine = new VengineMachine();
            _fileContext    = new FileContext(strategyImport);
            _printer        = new Printer(logger);
        }
Esempio n. 13
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));
        }
Esempio n. 14
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));
        }