public void AddVegetableToEmptyTrayTest()
        {
            var tray = new VegetableTray();

            tray.Add(new Tomato(), 8000);
            tray.Add(new Cabbage(), 5000);

            List <KeyValuePair <Vegetable, int> > cartItems = new List <KeyValuePair <Vegetable, int> >()
            {
                new KeyValuePair <Vegetable, int>(new Tomato(), 8000),
                new KeyValuePair <Vegetable, int>(new Cabbage(), 5000)
            };

            var trayVegetables = tray.GetVegetableQuantity();

            for (int i = 0; i < cartItems.Count; i++)
            {
                Assert.Equal(cartItems[i].Value, trayVegetables[i].Value);
            }
        }
Пример #2
0
        public void GetInsufficientVegetableQuantityTest()
        {
            var     inMemoryStorage = new InMemoryStorage();
            var     config          = new ConfigurationManager(inMemoryStorage);
            var     vegetableTray   = new VegetableTray();
            Tomato  tomato          = new Tomato();
            Cabbage cabbage         = new Cabbage();

            config.SetMinimumQuantity(tomato, 3);
            config.SetMinimumQuantity(cabbage, 1);

            vegetableTray.Add(tomato, 5);
            vegetableTray.Add(cabbage, 3);

            vegetableTray.TakeOut(tomato, 3);

            VegetableTracker vegetableTracker = new VegetableTracker(vegetableTray, config);

            Assert.AreEqual(1, vegetableTracker.GetInsufficientVegetableQuantity().Count);
        }
Пример #3
0
        public void VegetableTrayAddTest()
        {
            VegetableTray vegetableTray = new VegetableTray();
            Tomato        tomato        = new Tomato();
            Cabbage       cabbage       = new Cabbage();
            LadyFinger    ladyFinger    = new LadyFinger();

            vegetableTray.Add(tomato, 25);
            vegetableTray.Add(cabbage, 30);
            vegetableTray.Add(ladyFinger, 7);

            var actualVegetableQuantity = vegetableTray.GetVegetableQuantity();

            var expectedVegetableQuantity = new List <KeyValuePair <Vegetable, int> >();

            expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(tomato, 25));
            expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(cabbage, 30));
            expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(ladyFinger, 7));

            Assert.Equal(expectedVegetableQuantity, actualVegetableQuantity);
        }
        public void PlaceOrder()
        {
            Tomato  tomato  = new Tomato();
            Cabbage cabbage = new Cabbage();

            VegetableTray tray = new VegetableTray();

            tray.Add(tomato, 5000);
            tray.Add(cabbage, 4000);


            IStorage storage = new InMemoryStorage();

            ConfigurationManager configurationManager = new ConfigurationManager(storage);

            configurationManager.SetMinimumQuantity(tomato, 2000);
            configurationManager.SetMinimumQuantity(cabbage, 2000);

            tray.TakeOut(tomato, 4000);

            VegetableTracker vegetableTracker = new VegetableTracker(configurationManager, tray);
            var insufficientVegetables        = vegetableTracker.GetInsufficientVegetableQuantity();

            Order order = new Order(vegetableTracker, configurationManager, tray);

            order.PlaceOrder();

            List <KeyValuePair <Vegetable, int> > cartItems = new List <KeyValuePair <Vegetable, int> >()
            {
                new KeyValuePair <Vegetable, int>(new Tomato(), 2000),
                new KeyValuePair <Vegetable, int>(new Cabbage(), 4000)
            };

            var trayVegetables = tray.GetVegetableQuantity();

            for (int i = 0; i < cartItems.Count; i++)
            {
                Assert.Equal(cartItems[i].Value, trayVegetables[i].Value);
            }
        }
Пример #5
0
        public void PlaceOrderOfInsufficientVegetablesTest()
        {
            var vegetableTray        = new VegetableTray();
            var inMemoryStorage      = new InMemoryStorage();
            var configurationManager = new ConfigurationManager(inMemoryStorage);

            Tomato  tomato  = new Tomato();
            Cabbage cabbage = new Cabbage();

            configurationManager.SetMinimumQuantity(tomato, 3);
            configurationManager.SetMinimumQuantity(cabbage, 1);

            vegetableTray.Add(tomato, 1);
            vegetableTray.Add(cabbage, 3);

            var placeOrder      = new PlaceOrder(vegetableTray, configurationManager);
            var placedOrderList = new Dictionary <Vegetable, int>();

            placedOrderList.Add(tomato, 2);

            Assert.AreEqual(placedOrderList.Count, placeOrder.PlaceOrderOfInsufficientVegetables().Count);
        }
Пример #6
0
        public void VegetableTrayTakeOutExceptionTest()
        {
            VegetableTray vegetableTray = new VegetableTray();
            Tomato        tomato        = new Tomato();
            Cabbage       cabbage       = new Cabbage();
            LadyFinger    ladyFinger    = new LadyFinger();

            vegetableTray.Add(tomato, 25);

            var actualVegetableQuantity = vegetableTray.GetVegetableQuantity();

            Assert.Throws <VegetableNotFoundException>(() => vegetableTray.TakeOut(cabbage, 20));
        }
        public void InsufficientQauntity()
        {
            Tomato  tomato  = new Tomato();
            Cabbage cabbage = new Cabbage();

            VegetableTray tray = new VegetableTray();

            tray.Add(tomato, 5000);
            tray.Add(cabbage, 4000);
            tray.TakeOut(tomato, 4000);

            IStorage storage = new InMemoryStorage();

            ConfigurationManager configurationManager = new ConfigurationManager(storage);

            configurationManager.SetMinimumQuantity(tomato, 2000);
            configurationManager.SetMinimumQuantity(cabbage, 2000);

            VegetableTracker vegetableTracker = new VegetableTracker(configurationManager, tray);
            var insufficientVegetables        = vegetableTracker.GetInsufficientVegetableQuantity();

            Assert.Equal(tomato.Name, insufficientVegetables[0].Key.Name);
        }
        public void TakeOutVegetableFromTray()
        {
            var     tray    = new VegetableTray();
            Tomato  tomato  = new Tomato();
            Cabbage cabbage = new Cabbage();

            tray.Add(tomato, 8000);
            tray.Add(cabbage, 5000);
            tray.TakeOut(tomato, 2000);
            tray.TakeOut(cabbage, 2000);

            var trayVegetables = tray.GetVegetableQuantity();

            List <KeyValuePair <Vegetable, int> > cartItems = new List <KeyValuePair <Vegetable, int> >()
            {
                new KeyValuePair <Vegetable, int>(new Tomato(), 6000),
                new KeyValuePair <Vegetable, int>(new Cabbage(), 3000)
            };

            for (int i = 0; i < cartItems.Count; i++)
            {
                Assert.Equal(cartItems[i].Value, trayVegetables[i].Value);
            }
        }
Пример #9
0
 public void AddVegetable(Vegetable vegetable, int quantity)
 {
     _vegetableTray.Add(vegetable, quantity);
     _configurationManager = new ConfigurationManager(_storageFactory.GetStorage("database"));
 }
 public void AddVegetable(Vegetable vegetable, int quantity)
 {
     _vegetableTray.Add(vegetable, quantity);
 }
 public void AddVegetableToEmptyTrayTest()
 {
     tray.Add(cabbage, 2);
     tray.Add(tomato, 5);
     Assert.AreEqual(2, tray.GetVegetableQuantity().Count);
 }