public void ViewProductInMultipleStores()
        {
            userServices us      = userServices.getInstance();
            User         session = us.startSession();

            us.register(session, "zahi", "123456");
            us.login(session, "zahi", "123456");
            User aviad = us.startSession();

            us.register(aviad, "aviad", "123456");
            us.login(aviad, "aviad", "123456");
            storeServices ss  = storeServices.getInstance();
            int           id1 = ss.createStore("abowim", session);
            int           id2 = ss.createStore("bros", aviad);

            ss.addProductInStore("cola", 3.2, 10, session, id1, "drinks");
            ss.addProductInStore("sprite", 3.2, 10, session, id1, "drinks");
            ss.addProductInStore("milk", 3.2, 10, aviad, id2, "milk");
            LinkedList <ProductInStore> pisList     = us.viewProductsInStore(id1);
            LinkedList <ProductInStore> pisList2    = us.viewProductsInStore(id2);
            LinkedList <ProductInStore> piStorsList = us.viewProductsInStores();

            Assert.AreEqual(pisList.Count, 2);
            Assert.AreEqual(pisList2.Count, 1);
            Assert.AreEqual(piStorsList.Count, 3);
        }
Exemple #2
0
        public void AddSaleWithProductNotInStore()
        {
            int            storeid = ss.createStore("admin store", admin);
            Store          store2  = StoreManagement.getInstance().getStore(storeid);
            int            m       = ss.addProductInStore("milk", 3.2, 10, admin, storeid, "Drinks");
            ProductInStore milk    = ProductManager.getInstance().getProductInStore(m);

            Assert.AreEqual(ss.addSaleToStore(itamar, store.getStoreId(), milk.getProductInStoreId(), 1, 1, DateTime.Now.AddMonths(1).ToString()), -13); //-13 product not in this store
        }
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            configuration.DB_MODE = "Testing";
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            shippingProxy = new ShippingProxy();

            us    = userServices.getInstance();
            ss    = storeServices.getInstance();
            sellS = sellServices.getInstance();

            admin = us.startSession();
            us.register(admin, "admin", "123456");
            us.login(admin, "admin", "123456");

            admin1 = us.startSession();
            us.register(admin1, "admin1", "123456");

            zahi = us.startSession();
            us.register(zahi, "zahi", "123456");

            itamar = us.startSession();
            us.register(itamar, "itamar", "123456");
            us.login(itamar, "itamar", "123456");
            int storeId = ss.createStore("Maria&Netta Inc.", itamar);

            store = StoreManagement.getInstance().getStore(storeId);

            niv = us.startSession();
            us.register(niv, "niv", "123456");
            us.login(niv, "niv", "123456");

            ss.addStoreManager(storeId, "niv", itamar);

            int colaId = ss.addProductInStore("cola", 3.2, 10, itamar, storeId, "Drinks");

            cola = ProductManager.getInstance().getProductInStore(colaId);
            int spriteId = ss.addProductInStore("sprite", 5.2, 100, itamar, storeId, "Drinks");

            sprite = ProductManager.getInstance().getProductInStore(spriteId);
            ss.addSaleToStore(itamar, storeId, cola.getProductInStoreId(), 1, 10, DateTime.Now.AddMonths(10).ToString());
        }
Exemple #4
0
        public void init()
        {
            CleanDB cDB = new CleanDB();

            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            us    = userServices.getInstance();
            ss    = storeServices.getInstance();
            admin = us.startSession();
            us.register(admin, "admin", "123456");
            us.login(admin, "admin", "123456");

            admin1 = us.startSession();
            us.register(admin1, "admin1", "123456");

            zahi = us.startSession();
            us.register(zahi, "zahi", "123456");
            us.login(zahi, "zahi", "123456");

            itamar = us.startSession();
            us.register(itamar, "itamar", "123456");
            us.login(itamar, "itamar", "123456");



            int storeid = ss.createStore("MariaNettaInc", itamar);

            store = StoreManagement.getInstance().getStore(storeid);

            niv = us.startSession();
            us.register(niv, "niv", "123456");
            us.login(niv, "niv", "123456");

            ss.addStoreManager(store.getStoreId(), "niv", itamar);

            int c = ss.addProductInStore("cola", 3.2, 10, itamar, storeid, "Drinks");
            int s = ss.addProductInStore("sprite", 5.3, 20, itamar, storeid, "Drinks");

            cola       = ProductManager.getInstance().getProductInStore(c);
            sprite     = ProductManager.getInstance().getProductInStore(s);
            saleId     = ss.addSaleToStore(itamar, store.getStoreId(), cola.getProductInStoreId(), 1, 1, "20.5.2018");
            raffleSale = ss.addSaleToStore(itamar, store.getStoreId(), cola.getProductInStoreId(), 3, 1, "20.5.2018");
        }
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            us    = userServices.getInstance();
            ss    = storeServices.getInstance();
            sellS = sellServices.getInstance();

            admin = us.startSession();
            us.register(admin, "admin", "123456");
            us.login(admin, "admin", "123456");

            admin1 = us.startSession();
            us.register(admin1, "admin1", "123456");

            zahi = us.startSession();
            us.register(zahi, "zahi", "123456");
            us.login(zahi, "zahi", "123456");
            store2 = ss.createStore("Darkness Inc.", zahi);

            itamar = us.startSession();
            us.register(itamar, "itamar", "123456");
            us.login(itamar, "itamar", "123456");
            store = ss.createStore("Maria&Netta Inc.", itamar);

            niv = us.startSession();
            us.register(niv, "niv", "123456");
            us.login(niv, "niv", "123456");

            ss.addStoreManager(store, "niv", itamar);

            cola    = ss.addProductInStore("cola", 3.2, 10, itamar, store, "drinks");
            sprite  = ss.addProductInStore("sprite", 5.3, 20, itamar, store, "drinks");
            chicken = ss.addProductInStore("chicken", 50, 20, zahi, store2, "drinks");
            cow     = ss.addProductInStore("cow", 80, 40, zahi, store2, "food");
            saleId1 = ss.addSaleToStore(itamar, store, cola, 1, 5, "20/5/2018");
            saleId2 = ss.addSaleToStore(zahi, store2, chicken, 1, 15, "20/7/2019");
        }
Exemple #6
0
        public void init()
        {
            CleanDB cDB = new CleanDB();

            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();
            us   = userServices.getInstance();
            ss   = storeServices.getInstance();
            zahi = us.startSession();
            us.register(zahi, "zahi", "123456");
            us.login(zahi, "zahi", "123456");
            int storeid = ss.createStore("abowim", zahi);

            store = StoreManagement.getInstance().getStore(storeid);
            int c = ss.addProductInStore("cola", 3.2, 10, zahi, storeid, "Drinks");

            cola = ProductManager.getInstance().getProductInStore(c);
        }
        public void SimpleViewProductWithTwoProducts()
        {
            userServices us      = userServices.getInstance();
            User         session = us.startSession();

            us.register(session, "zahi", "123456");
            us.login(session, "zahi", "123456");
            storeServices ss  = storeServices.getInstance();
            int           id1 = ss.createStore("abowim", session);

            ss.addProductInStore("cola", 3.2, 10, session, id1, "drinks");
            ss.addProductInStore("sprite", 3.2, 10, session, id1, "drinks");
            LinkedList <ProductInStore> pisList     = us.viewProductsInStore(id1);
            LinkedList <ProductInStore> piStorsList = us.viewProductsInStores();

            Assert.AreEqual(pisList.Count, 2);
            Assert.AreEqual(piStorsList.Count, 2);
        }
Exemple #8
0
        public void simpleViewHistory()
        {
            User aviad = us.startSession();

            Assert.IsNotNull(aviad);
            int store = ss.createStore("abowim", zahi);

            Assert.IsNotNull(store);
            Assert.IsTrue(us.register(aviad, "aviad", "123456") > -1);
            Assert.IsTrue(us.login(aviad, "aviad", "123456") > -1);
            int pis    = ss.addProductInStore("cola", 3.2, 10, zahi, store, "drinks");
            int saleId = ss.addSaleToStore(zahi, store, pis, 1, 8, DateTime.Now.AddDays(10).ToString());
            LinkedList <Sale> sales = ses.viewSalesByProductInStoreId(pis);

            Assert.IsTrue(sales.Count == 1);
            Sale sale = sales.First.Value;

            Assert.IsTrue(ses.addProductToCart(aviad, sale.SaleId, 2) > -1);
            LinkedList <UserCart> sc = ses.viewCart(aviad);

            Assert.IsTrue(sc.Count == 1);
            Assert.IsTrue(sc.First.Value.getSaleId() == saleId);
            Assert.IsTrue(ses.buyProducts(aviad, "1234", ""));
            LinkedList <Purchase> historyList = ss.viewStoreHistory(zahi, store);

            Assert.IsTrue(historyList.Count == 1);
            Assert.IsTrue(historyList.First.Value.ProductId == ProductManager.getInstance().getProductInStore(pis).getProduct().getProductId());
            Assert.IsTrue(historyList.First.Value.Amount == 2);
        }
Exemple #9
0
        public void ViewSlaeInStoreFewStors()
        {
            int saleId1 = ss.addSaleToStore(itamar, store.getStoreId(), cola.getProductInStoreId(), 1, 1, "20/5/2018");
            LinkedList <Sale> saleList1 = ss.viewSalesByStore(store.getStoreId());
            int               storeId   = ss.createStore("admin store", admin);
            Store             store2    = StoreManagement.getInstance().getStore(storeId);
            int               milkId    = ss.addProductInStore("milk", 3.2, 10, admin, store2.getStoreId(), "Drinks");
            ProductInStore    milk      = ProductManager.getInstance().getProductInStore(milkId);
            int               saleId2   = ss.addSaleToStore(admin, store2.getStoreId(), milk.getProductInStoreId(), 1, 1, "20/5/2018");
            LinkedList <Sale> saleList2 = ss.viewSalesByStore(store2.getStoreId());

            Assert.AreEqual(saleList1.Count, 1);
            Assert.AreEqual(saleId1, saleList1.First.Value.SaleId);
            Assert.AreEqual(saleList2.Count, 1);
            Assert.AreEqual(saleId2, saleList2.First.Value.SaleId);
        }
Exemple #10
0
        public void init()
        {
            CleanDB cDB = new CleanDB();

            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            us  = userServices.getInstance();
            ss  = storeServices.getInstance();
            ses = sellServices.getInstance();

            zahi = us.startSession();
            us.register(zahi, "zahi", "123456");
            us.login(zahi, "zahi", "123456");
            itamar = us.startSession();
            us.register(itamar, "itamar", "123456");
            us.login(itamar, "itamar", "123456");

            int storeid = ss.createStore("abowim", zahi);

            store = StoreManagement.getInstance().getStore(storeid);

            int colaId = ss.addProductInStore("cola", 10, 100, zahi, storeid, "Drinks");

            cola = ProductManager.getInstance().getProductInStore(colaId);

            ss.addSaleToStore(zahi, store.getStoreId(), cola.getProductInStoreId(), 1, 20, "20/8/2018");

            LinkedList <Sale> SL = ss.viewSalesByStore(store.getStoreId());

            foreach (Sale sale in SL)
            {
                if (sale.ProductInStoreId == cola.getProductInStoreId())
                {
                    colaSale = sale;
                }
            }
        }
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            us   = userServices.getInstance();
            ss   = storeServices.getInstance();
            sell = sellServices.getInstance();

            admin = us.startSession();
            us.register(admin, "admin", "123456");
            us.login(admin, "admin", "123456");

            admin1 = us.startSession();
            us.register(admin1, "admin1", "123456");

            zahi = us.startSession();
            us.register(zahi, "zahi", "123456");

            itamar = us.startSession();
            us.register(itamar, "itamar", "123456");
            us.login(itamar, "itamar", "123456");
            store = ss.createStore("Maria&Netta Inc.", itamar);

            niv = us.startSession();
            us.register(niv, "niv", "123456");
            us.login(niv, "niv", "123456");

            ss.addStoreManager(store, "niv", itamar);

            cola       = ss.addProductInStore("cola", 3.2, 10, itamar, store, "drinks");
            saleId     = ss.addSaleToStore(itamar, store, cola, 1, 1, "20.5.2018");
            raffleSale = ss.addSaleToStore(itamar, store, cola, 3, 1, "20.5.2018");
        }
Exemple #12
0
 public void addProductInStore()
 {
     ss.removeManagerPermission("addProductInStore", store.getStoreId(), "aviad", zahi);
     ss.addProductInStore("cola", 10, 4, aviad, store.getStoreId(), "Drink");
     Assert.AreEqual(0, store.getProductsInStore().Count);
 }
        public void SimpleRemoveProduct()
        {
            us.login(zahi, "zahi", "123456");
            int            storeId = ss.createStore("abowim", zahi);
            Store          s       = StoreManagement.getInstance().getStore(storeId);
            int            pisId   = ss.addProductInStore("cola", 3.2, 10, zahi, storeId, "Drink");
            ProductInStore pis     = ProductManager.getInstance().getProductInStore(pisId);
            int            result  = ss.removeProductFromStore(s.storeId, pis.productInStoreId, zahi);

            Assert.IsTrue(result > -1);
            LinkedList <ProductInStore> LPIS = us.viewProductsInStores();

            Assert.AreEqual(LPIS.Count, 0);
        }
        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);
        }