public void removeDiscountWithManagerPermission() { ProductInStore pis = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 150, 100, zahi, store.getStoreId(), "Drink")); int saleId = ss.addSaleToStore(zahi, store.getStoreId(), pis.getProductInStoreId(), 1, 40, DateTime.Now.AddYears(1).ToString()); ss.removeManagerPermission("removeDiscount", store.getStoreId(), aviad.getUserName(), zahi); Assert.IsTrue(ss.addDiscount(pis, 10, DateTime.Now.AddDays(1).ToString(), aviad, store)); Boolean removed = ss.removeDiscount(pis, store, aviad); Assert.AreEqual(1, DiscountsManager.getInstance().getAllDiscounts().Count); Assert.AreEqual(false, removed); }
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 colaId = ss.addProductInStore("cola", 10, 100, zahi, store.getStoreId(), "Drinks"); cola = ProductManager.getInstance().getProductInStore(colaId); ss.addSaleToStore(zahi, store.getStoreId(), cola.getProductInStoreId(), 1, 2, DateTime.Now.AddDays(5).ToString()); LinkedList <Sale> SL = ss.viewSalesByStore(store.getStoreId()); foreach (Sale sale in SL) { if (sale.ProductInStoreId == cola.getProductInStoreId()) { colaSale = sale; } } ss.addDiscount(cola, 10, DateTime.Now.AddDays(5).ToString(), zahi, store); }
public void simpleAddDiscount() { Assert.IsTrue(ss.addDiscount(cola, 10, DateTime.Now.AddDays(10).ToString(), zahi, store)); Assert.AreEqual(colaSale.getPriceAfterDiscount(1), 9); }