public void ViewSlaeInStoreAsMannegerWithoutPremition() { int saleId = aviadManeger.addSaleToStore(zahi, store, cola.getProductInStoreId(), 1, 1, "20/5/2018"); LinkedList <Sale> saleList = store.getAllSales(); Assert.AreEqual(saleList.Count, 0); }
public void ViewSlaeInStoreAsMannegerWithPremition() { zahiOwner.addManagerPermission(zahi, "addSaleToStore", store, "aviad"); aviadManeger = new StoreManager(aviad, store); int saleId = aviadManeger.addSaleToStore(aviad, store, cola.getProductInStoreId(), 1, 1, "20/5/2018"); LinkedList <Sale> saleList = store.getAllSales(); Assert.AreEqual(saleList.Count, 1); }
/* * return: * 0 > on sucess the SaleID * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal product name * -4 if don't have premition * -5 if illegal amount bigger then amount in stock * -6 if illegal store id * -7 if illegal price * -8 if illegal product in store Id * -9 database eror * -10 due date not good * -11 illegal type of sale not * -12 if illegal amount * -13 product not in this store */ public int addSaleToStore(User session, int storeId, int productInStoreId, int typeOfSale, int amount, String dueDate) { Store s = StoreManagement.getInstance().getStore(storeId); if (session == null || !session.getState().isLogedIn()) { return(-1);//-1 if user Not Login } StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1);//-4 if don't have premition } return(sR.addSaleToStore(session, s, productInStoreId, typeOfSale, amount, dueDate)); }
public void simpleAddSalePolicyToStore() { Assert.IsTrue(zahiOwner.setAmountPolicyOnStore(zahi, store.getStoreId(), 2, 10) > -1); int saleId = zahiOwner.addSaleToStore(zahi, store, cola.getProductInStoreId(), 1, 20, DateTime.Now.AddMonths(1).ToString()); Assert.IsTrue(saleId > -1); LinkedList <Sale> sales = User.viewSalesByProductInStoreId(cola.getProductInStoreId()); Assert.IsTrue(sales.Count == 1); Sale sale = sales.First.Value; Assert.IsTrue(aviad.addToCart(sale.SaleId, 2) > -1); LinkedList <UserCart> sc = aviad.getShoppingCartBeforeCheckout(); Assert.IsTrue(aviad.checkout("Israel", "mazada 69").Item1 == -1); }
public void SimpleAddSaleeWithManagerPermission() { zahiOwner.addManagerPermission(zahi, "addSaleToStore", store, "aviad"); Assert.IsTrue(aviadManeger.addSaleToStore(aviad, store, cola.getProductInStoreId(), 1, 1, DateTime.Now.AddMonths(1).ToString()) > -1); Assert.AreEqual(store.getAllSales().Count, 1); }
public void SimpleAddSaleeWithOwner() { Assert.IsTrue(zahiOwner.addSaleToStore(zahi, store, cola.getProductInStoreId(), 1, 1, DateTime.Now.AddMonths(1).ToString()) > -1); Assert.AreEqual(store.getAllSales().Count, 1); }
public void ViewSlaeInStore() { int saleId = zahiOwner.addSaleToStore(zahi, store, cola.getProductInStoreId(), 1, 1, "20/5/2018"); LinkedList <Sale> saleList = store.getAllSales(); Assert.AreEqual(saleList.Count, 1); Assert.AreEqual(saleId, saleList.First.Value.SaleId); }
public void AddProductToCart() { int saleId = zahiOwner.addSaleToStore(zahi, store, cola.getProductInStoreId(), 1, 5, DateTime.Now.AddMonths(1).ToString()); LinkedList <Sale> saleList = store.getAllSales(); Assert.IsTrue(aviad.addToCart(saleList.First.Value.SaleId, 1) > -1); Assert.AreEqual(aviad.getShoppingCart().First.Value.getSaleId(), saleId); }