예제 #1
0
        public void editProductInStoreWithoutManagerPermission()
        {
            int            pisId = zahiOwner.addProductInStore(zahi, store, "cola2", 10, 4, "Drinks");
            ProductInStore pis   = ProductManager.getInstance().getProductInStore(pisId);

            Assert.AreEqual(2, store.getProductsInStore().Count);
            aviadManeger.editProductInStore(aviad, pis, 13, 4.5);
            Assert.AreEqual(10, pis.getPrice());
            Assert.AreEqual(4, pis.getAmount());
            zahiOwner.addManagerPermission(zahi, "addSaleToStore", store, "aviad");
            aviadManeger.editProductInStore(aviad, pis, 13, 4.5);
            Assert.AreEqual(10, pis.getPrice());
            Assert.AreEqual(4, pis.getAmount());
        }
예제 #2
0
        public void getProductInStoreQuantity()
        {
            Store          store       = new Store(1, "halavi", null);
            Product        milk        = productArchive.addProduct("milk");
            ProductInStore milkInStore = productArchive.addProductInStore(milk, store, 50, 50);
            int            quantity    = ProductManager.getInstance().getProductInStoreQuantity(milkInStore.getProductInStoreId());

            Assert.AreEqual(quantity, milkInStore.getAmount());
        }
예제 #3
0
        public void editProductInStoreWithManagerPermission()
        {
            ProductInStore pis = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 10, 4, zahi, store.getStoreId(), "Drink"));

            Assert.AreEqual(1, store.getProductsInStore().Count);
            ss.removeManagerPermission("editProductInStore", store.getStoreId(), "aviad", zahi);
            ss.editProductInStore(aviad, store.getStoreId(), pis.getProductInStoreId(), 13, 4.5);
            Assert.AreEqual(10, pis.getPrice());
            Assert.AreEqual(4, pis.getAmount());
        }
예제 #4
0
        public void addNewProductInStore()
        {
            Store          store       = new Store(1, "halavi", null);
            Product        milk        = productArchive.addProduct("milk");
            ProductInStore milkInStore = productArchive.addProductInStore(milk, store, 50, 50);

            Assert.IsTrue(milkInStore != null);
            Assert.AreEqual(milkInStore.getPrice(), 50);
            Assert.AreEqual(milkInStore.getProduct(), milk);
            Assert.AreEqual(milkInStore.getAmount(), 50);
            Assert.AreEqual(milkInStore.getStore(), store);
        }
        public void SimpleAddProduct()
        {
            int            storeid = ss.createStore("abowim", zahi);
            Store          s       = StoreManagement.getInstance().getStore(storeid);
            int            p       = ss.addProductInStore("cola", 3.2, 10, zahi, storeid, "Drinks");
            ProductInStore pis     = ProductManager.getInstance().getProductInStore(p);

            Assert.AreEqual(pis.getPrice(), 3.2);
            Assert.AreEqual(pis.getAmount(), 10);
            Assert.AreEqual(pis.getStore().getStoreId(), s.getStoreId());
            LinkedList <ProductInStore> pList = s.getProductsInStore();

            Assert.IsTrue(pList.Contains(pis));
            Assert.AreEqual(pList.Count, 1);
        }
예제 #6
0
        public void editExistingProductInStore()
        {
            Store          store        = new Store(1, "halavi", null);
            Product        milk         = productArchive.addProduct("milk");
            ProductInStore breadInStore = productArchive.addProductInStore(milk, store, 50, 50);

            // at this point bread is in store - already been tested
            breadInStore.Quantity = 200;
            breadInStore.Price    = 3000;
            int     id    = breadInStore.getProductInStoreId();
            Boolean check = productArchive.updateProductInStore(breadInStore);

            Assert.IsTrue(check);
            ProductInStore b = productArchive.getProductInStore(id);

            Assert.AreEqual(b.getPrice(), 3000);
            Assert.AreEqual(b.getAmount(), 200);
        }
예제 #7
0
 public void simpleEditProductInStore()
 {
     Assert.AreEqual(ss.editProductInStore(zahi, store.getStoreId(), cola.getProductInStoreId(), 100, 5.2), 0);
     Assert.AreEqual(cola.getAmount(), 100);
     Assert.AreEqual(cola.getPrice(), 5.2);
 }