Ejemplo n.º 1
0
        public void addManagerPermission()
        {
            zahiOwner.addManagerPermission(zahi, "addManagerPermission", store, "aviad");
            Assert.IsTrue(zahiOwner.addStoreManager(zahi, store, "shay") > -1);
            Assert.AreEqual(store.getManagers().Count, 2);
            aviadManeger.addManagerPermission(aviad, "removeStoreManager", store, "shay");
            StoreManager shaymanneger = new StoreManager(shay, store);

            Assert.IsTrue(shaymanneger.removeStoreManager(shay, store, "aviad") > -1);
            Assert.AreEqual(store.getManagers().Count, 1);
        }
Ejemplo n.º 2
0
        public void RemoveProductFromStoreAsMannegerWithPremission()
        {
            zahiOwner.addManagerPermission(zahi, "removeProductFromStore", store, "aviad");
            aviadManeger = new StoreManager(aviad, store);
            int result = aviadManeger.removeProductFromStore(aviad, store, cola);

            Assert.IsTrue(result > -1);
            LinkedList <ProductInStore> LPIS = store.getProductsInStore();

            Assert.AreEqual(LPIS.Count, 0);
        }
Ejemplo n.º 3
0
        //req 3.4 c

        /*
         *       return:
         *           0 on sucess
         *          -1 if user Not Login
         *          -2 if Store Name already exist
         *          -3 if illegal store id
         *          -4 if don't have premition
         *          -5 database eror
         *          -6 manager name doesn't exsist
         *          -7 no such premition
         *          -8 the mannager to add is not a manager in this store
         *          -10 can't remove himself
         */
        public int addManagerPermission(String permission, int storeId, String managerToAdd, User session)
        {
            Store     s  = StoreManagement.getInstance().getStore(storeId);
            StoreRole sR = StoreRole.getStoreRole(s, session);

            if (sR == null)
            {
                return(-4); //-4 if don't have premition
            }
            return(sR.addManagerPermission(session, permission, s, managerToAdd));
        }
Ejemplo n.º 4
0
        public void editProductInStoreWithManagerPermission()
        {
            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, "editProductInStore", store, "aviad");
            aviadManeger.editProductInStore(aviad, pis, 13, 4.5);
            Assert.AreEqual(4.5, pis.getPrice());
            Assert.AreEqual(13, pis.getAmount());
        }