public void checkoutWithNoDiscountPurchasePolicyOnProductInCountry() { // 1-Product(system level) , 2- Store, 3-category, 4- product in store, 5-country discountsArchive.addNewDiscount(colaInStore.getProductInStoreId(), 1, "", 50, DateTime.Now.AddDays(20).ToString(), ""); PurchasePolicyManager.getInstance().setNoDiscountPolicyOnCountry(store.storeId, "England"); itamar.addToCart(colaRegularSale.SaleId, 5); itamar.getShoppingCartBeforeCheckout(); Tuple <int, LinkedList <UserCart> > ans = itamar.checkout("England", "ben gurion 13"); Assert.AreEqual(ans.Item1, -1); Assert.AreEqual(ans.Item2.First.Value.Price, 2500); Assert.AreEqual(ans.Item2.First.Value.PriceAfterDiscount, 2500); }
public void init() { // ARCHIVE INIT WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB(); cDB.emptyDB(); PurchasePolicyManager.restartInstance(); SalesManager.restartInstance(); DiscountsManager.restartInstance(); CouponsManager.restartInstance(); StoreManagement.restartInstance(); UserManager.restartInstance(); ProductManager.restartInstance(); UserCartsManager.restartInstance(); purchasePolicyArchive = PurchasePolicyManager.getInstance(); salesArchive = SalesManager.getInstance(); discountsArchive = DiscountsManager.getInstance(); couponsArchive = CouponsManager.getInstance(); productArchive = ProductManager.getInstance(); StoreManagement = StoreManagement.getInstance(); userArchive = UserManager.getInstance(); // USERS INIT admin = new User("admin", "123456"); admin.register("admin", "123456"); admin.login("admin", "123456"); storeOwner = new User("owner", "123456"); storeOwner.register("owner", "123456"); storeOwner.login("owner", "123456"); itamar = new User("itamar", "123456"); itamar.register("itamar", "123456"); itamar.login("itamar", "123456"); shay = new User("shay", "123456"); shay.register("shay", "123456"); shay.login("shay", "123456"); // PRODUCTS INIT cola = productArchive.addProduct("cola"); sprite = productArchive.addProduct("sprite"); // STORES AND PRODUCTS IN STORES store = StoreManagement.addStore("samsung", storeOwner); colaInStore = productArchive.addProductInStore(cola, store, 200, 500, "cola category"); spriteInStore = productArchive.addProductInStore(sprite, store, 100, 200, "sprite category"); // SALES INIT colaRegularSale = salesArchive.addSale(colaInStore.getProductInStoreId(), regularSale, 50, DateTime.Now.AddDays(10).ToString()); spriteRaffleSale = salesArchive.addSale(spriteInStore.getProductInStoreId(), raffleSale, 3, DateTime.Now.AddDays(20).ToString()); }
public string showPolicy(User session, int productInStoreId) { return(PurchasePolicyManager.getInstance().showPolicy(productInStoreId)); }