Exemplo n.º 1
0
        public void TakeOne_NonExistingBarcode_ExceptionThrown()
        {
            IEnumerable<ProductCollection> draft = new List<ProductCollection>
            {
                new ProductCollection(new Product(Guid.NewGuid(), "Cupcake", 50), 4),
                new ProductCollection(new Product(Guid.NewGuid(), "Cookie", 10), 3),
                new ProductCollection(new Product(Guid.NewGuid(), "Waffle", 30), 10)
            };

            Menu menu = new Menu(draft);

            menu.TakeOne(Guid.NewGuid());
        }
Exemplo n.º 2
0
        public void TakeOne_NoItemsLeft_ExceptionThrown()
        {
            Guid waffleGuid = Guid.NewGuid();
            Int32 waffleAmount = 0;

            IEnumerable<ProductCollection> draft = new List<ProductCollection>
            {
                new ProductCollection(new Product(Guid.NewGuid(), "Cupcake", 50), 0),
                new ProductCollection(new Product(Guid.NewGuid(), "Cookie", 10), 3),
                new ProductCollection(new Product(waffleGuid, "Waffle", 30), waffleAmount)
            };

            Menu menu = new Menu(draft);

            menu.TakeOne(waffleGuid);
        }
Exemplo n.º 3
0
        public void TakeOne_ExistingBarcode_RightItemReturned()
        {
            Guid waffleGuid = Guid.NewGuid();

            IEnumerable<ProductCollection> draft = new List<ProductCollection>
            {
                new ProductCollection(new Product(Guid.NewGuid(), "Cupcake", 50), 4),
                new ProductCollection(new Product(Guid.NewGuid(), "Cookie", 10), 3),
                new ProductCollection(new Product(waffleGuid, "Waffle", 30), 10)
            };

            Menu menu = new Menu(draft);

            Product waffle = menu.TakeOne(waffleGuid);

            Assert.AreEqual(waffle.Barcode, waffleGuid);
        }
Exemplo n.º 4
0
        public void TakeOne_ExistingBarcode_AmountDecreased()
        {
            Guid waffleGuid = Guid.NewGuid();
            Int32 waffleAmount = 10;

            IEnumerable<ProductCollection> draft = new List<ProductCollection>
            {
                new ProductCollection(new Product(Guid.NewGuid(), "Cupcake", 50), 4),
                new ProductCollection(new Product(Guid.NewGuid(), "Cookie", 10), 3),
                new ProductCollection(new Product(waffleGuid, "Waffle", 30), waffleAmount)
            };

            Menu menu = new Menu(draft);

            Product waffle = menu.TakeOne(waffleGuid);

            Assert.AreEqual(menu.GetAmount(waffleGuid), waffleAmount - 1);
        }
        public void Configure(Menu menu)
        {
            if (menu == null) throw new NullReferenceException();

            _vendingMachineMenu = menu;
        }
 public VendingMachineSeller(Menu menu, VendingMachineBalance balance)
 {
     Configure(menu);
     Configure(balance);
 }