public void addStoreTest() { Store s1 = new Store("store", "store"); int ID = DBStore.getInstance().addStore(s1); Assert.AreNotEqual(DBStore.getInstance().getStore(ID), null); }
public void closeStoreTest() { int ID = DBStore.getInstance().addStore(s); DBStore.getInstance().closeStore(s); Assert.IsFalse(s.isActive()); }
public void addToCartTest1() { Product p1 = new Product("p1", "ff", 56, 2, 10, DBStore.getInstance().getStore(store1)); basket.addToCart(p1, 5); Assert.AreEqual(basket.getShoppingCarts().Keys.Count, 1); }
public void addManager(int storeid, string username, bool editProduct, bool editDiscount, bool editPolicy, Session session) { SubscribedUser toAdd = DBSubscribedUser.getInstance().getSubscribedUser(username); if (toAdd == null) { throw new DoesntExistException("no such username"); } Store store = DBStore.getInstance().getStore(storeid); if (store == null) { throw new DoesntExistException("no such store"); } StoreRole sr = store.getStoreRole(session.getSubscribedUser()); if (sr.getStore() != store) { throw new RoleException("this user can't appoint to this store"); } Permissions permissions = new Permissions(editProduct, editDiscount, editPolicy); sr.addManager(toAdd, permissions); }
public void TestInitialize() { DBStore.getInstance().DBinit(); s = new Store("store", "store"); su = new SubscribedUser("u", "u", new ShoppingBasket()); sr = new StoreOwner(null, su, s); }
public void TestInitialize() { storeService = StoreService.getInstance(); userService = UserService.getInstance(); DBStore.getInstance().init(); DBSubscribedUser.getInstance().cleanDB(); }
public void removeStoreTest() { int ID = DBStore.getInstance().addStore(s); Assert.AreEqual(DBStore.getInstance().removeStore(s), ""); Assert.AreEqual(DBStore.getInstance().getStore(ID), null); Assert.AreNotEqual(DBStore.getInstance().removeStore(s), ""); }
public void TestInitialize() { MarketSystem.initTestWitOutRead(); s = new Store("store", "store"); DBStore.getInstance().addStore(s); su = new SubscribedUser("u", "u", new ShoppingBasket()); sr = new StoreOwner(null, su, s); }
public void Initialize() { userService = UserService.getInstance(); storeService = StoreService.getInstance(); session = userService.startSession(); DBStore.getInstance().init(); DBSubscribedUser.getInstance().cleanDB(); }
public int addProduct(string productName, string productCategory, int price, int rank, int quantityLeft, int storeID, Session session) { DBStore storeDB = DBStore.getInstance(); Store store = storeDB.getStore(storeID); StoreRole sr = store.getStoreRole(session.getSubscribedUser()); Product product = new Product(productName, productCategory, price, rank, quantityLeft, store); sr.addProduct(product); return(product.getProductID()); }
public void initial() { MarketSystem.initTestWitOutRead(); //DBProduct.getInstance().initTests(); //DBProduct.getInstance().initTests(); //DBStore.getInstance().initTests(); store = new Store("store1", "games store"); DBStore.getInstance().addStore(store); cart = new ShoppingCart(store.getStoreID()); }
public void closeStore(int storeid, Session session) { Store store = DBStore.getInstance().getStore(storeid); if (store == null) { throw new DoesntExistException("no such store"); } session.closeStore(store); }
public TotalPricePolicy(int totalPrice) { if (totalPrice < 0) { throw new ILLArgumentException("total price can not be a negative number."); } this.totalPrice = totalPrice; this.policyID = DBStore.getInstance().getNextPolicyID(); }
public void createStoreTest() { Session session = new Session(); session.register("yael", "yael"); session.login("yael", "yael"); Store store = session.getState().createStore("Wallmart", "sells everything", session.getSubscribedUser()); Assert.IsTrue(store != null); DBStore.getInstance().cleanDB(); }
public void decFromProductQuantity(int productid, int amount, Session session) { Product product = DBProduct.getInstance().getProductByID(productid); if (product == null) { throw new DoesntExistException("no such username"); } SubscribedUser user = session.getSubscribedUser(); StoreRole sr = DBStore.getInstance().getStoreRole(product.getStore(), user); sr.decFromProductQuantity(product, amount); }
public void removeProduct(int productid, Session session) { Product product = DBProduct.getInstance().getProductByID(productid); if (product == null) { throw new DoesntExistException("no such username"); } SubscribedUser user = session.getSubscribedUser(); StoreRole sr = DBStore.getInstance().getStoreRole(product.getStore(), user); sr.removeProduct(product); }
public void setProductDiscount(int productid, int discount, Session session) { Product product = DBProduct.getInstance().getProductByID(productid); if (product == null) { throw new DoesntExistException("no such username"); } SubscribedUser user = session.getSubscribedUser(); DBStore storeDB = DBStore.getInstance(); StoreRole sr = storeDB.getStoreRole(product.getStore(), user); //??????????????????????????????/ //sr.setProductDiscount(product, discount); }
public ComplexPurchasePolicy(string type, PurchasePolicy p1, PurchasePolicy p2) { if (type == "xor") { this.type = Type.xor; } else if (type == "or") { this.type = Type.or; } else { this.type = Type.and; } this.p1 = p1; this.p2 = p2; this.policyID = DBStore.getInstance().getNextPolicyID(); }
public void addOwner(int storeid, string username, Session session) { SubscribedUser toAdd = DBSubscribedUser.getInstance().getSubscribedUser(username); if (toAdd == null) { throw new DoesntExistException("no such username"); } Store store = DBStore.getInstance().getStore(storeid); if (store == null) { throw new DoesntExistException("no such store"); } StoreRole sr = store.getStoreRole(session.getSubscribedUser()); if (sr.getStore() != store) { throw new RoleException("this user can't appoint to this store"); } sr.addOwner(toAdd); }
public void removeRole(int storeid, string username, Session session) { SubscribedUser toRemove = DBSubscribedUser.getInstance().getSubscribedUser(username); if (toRemove == null) { throw new DoesntExistException("no such username"); } Store store = DBStore.getInstance().getStore(storeid); if (store == null) { throw new DoesntExistException("no such store"); } StoreRole sr = store.getStoreRole(session.getSubscribedUser()); if (sr.getStore() != store) { throw new RoleException("this user can't remove roles from this store"); } sr.remove(toRemove); }
public void addStoreRoleTest() { DBStore.getInstance().addStoreRole(sr); Assert.AreEqual(DBStore.getInstance().getStoreRole(s, su), sr); }
public void removeStoreRoleTest() { DBStore.getInstance().addStoreRole(sr); DBStore.getInstance().removeStoreRole(sr); Assert.AreEqual(DBStore.getInstance().getStoreRole(s, su), null); }