public void setUp() { service = ServiceLayer.getInstance(false); idOwner = service.initUser(); DBtransactions db = DBtransactions.getInstance(true); db.isTest(true); ownerUser = "******"; passwordUser = "******"; service.register(ownerUser, passwordUser, idOwner); service.signIn(ownerUser, passwordUser); idManager = service.initUser(); managerUser = "******"; managerPassword = "******"; service.register(managerUser, managerPassword, idManager); permissions = new List <String>() { "AddDiscountPolicy" }; service.openStore("adidas", ownerUser); idGuest = service.initUser(); guestUser = "******"; password = "******"; }
public void setUp() { DBtransactions.getInstance(true); system = new TradingSystem(null, null); ownerUser = new User(1234, "Seifan", "2457", false, false); ownerUser.register(ownerUser.UserName, ownerUser.Password); ownerUser.signIn(ownerUser.UserName, ownerUser.Password); store = new Store(1111, "adidas"); ownerRole = new Owner(store, ownerUser); ownerUser.Roles.Add(store.Id, ownerRole); managerUser = new User(7878, "baba", "3434", false, false); managerUser.register(managerUser.UserName, managerUser.Password); permissions = new List <int>(); permissions.Add(1); managerRole = new Manager(store, managerUser, permissions); user1 = new User(2456, "luli", "5656", false, false); store.Roles = new TreeNode <Role>(ownerRole); store.RolesDictionary.Add(ownerUser.Id, new TreeNode <Role>(ownerRole)); system.Users.Add(ownerUser.Id, ownerUser); system.Users.Add(managerUser.Id, managerUser); system.Users.Add(user1.Id, user1); system.Stores.Add(store.Id, store); }
public void TestMethod1_basket_updateSenrio() { setUp(); DBtransactions.getInstance(true); Assert.AreEqual(0, basket_user.ShoppingCarts.Count); LinkedList <KeyValuePair <Product, int> > toInsert = new LinkedList <KeyValuePair <Product, int> >(); Assert.AreEqual(null, basket_user.addProductsToCart(toInsert, store.Id, user.Id)); toInsert.AddLast(new KeyValuePair <Product, int>(this.p1, 10)); Assert.AreEqual(0, basket_user.ShoppingCarts.Count); Assert.AreEqual(expected: store.Id, actual: basket_user.addProductsToCart(toInsert, store.Id, user.Id).StoreId); Assert.AreEqual(1, basket_user.ShoppingCarts.Count); StubCart cart = new StubCart(-1, null, 10); cart.copy(basket_user.ShoppingCarts[store.Id]); basket_user.ShoppingCarts[store.Id] = cart; Assert.AreEqual(1, basket_user.ShoppingCarts.Count); Assert.AreEqual(10, basket_user.ShoppingCarts[cart.StoreId].Products[this.p1.Id].Quantity); Assert.AreEqual(expected: null, actual: basket_user.addProductsToCart(toInsert, store.Id, user.Id)); Assert.AreEqual(1, basket_user.ShoppingCarts.Count); Assert.AreEqual(20, basket_user.ShoppingCarts[cart.StoreId].Products[this.p1.Id].Quantity); }
public void setUp() { DBtransactions db = DBtransactions.getInstance(true); admin = new User(0, "admin", "123456", true, true); basket_admin = admin.Basket; user = new User(1, null, null, false, false); basket_user = user.Basket; store = new Store(-1, "store"); p1 = new Product(0, "first", null, "", 5000); p2 = new Product(1, "second", null, "", 5000); p3 = new Product(2, "third", null, "", 5000); p4 = new Product(3, "fourth", null, "", 5000); pis1 = new ProductInStore(10000000, store, p1); pis2 = new ProductInStore(10000000, store, p2); pis3 = new ProductInStore(10000000, store, p3); pis4 = new ProductInStore(10000000, store, p4); store.Products.Add(p1.Id, pis1); store.Products.Add(p2.Id, pis2); store.Products.Add(p3.Id, pis3); store.Products.Add(p4.Id, pis4); sys = new TradingSystem(null, null); sys.StoreCounter = 1; sys.ProductCounter = 4; sys.UserCounter = 2; sys.Stores.Add(store.Id, store); sys.Users.Add(admin.Id, admin); sys.Users.Add(user.Id, user); }
public void setUp() { service = ServiceLayer.getInstance(false); DBtransactions db = DBtransactions.getInstance(true); db.isTest(true); idOwner = service.initUser(); ownerUser = "******"; passwordUser = "******"; service.register(ownerUser, passwordUser, idOwner); service.signIn(ownerUser, passwordUser); idUser = service.initUser(); tmpUser = "******"; passUser = "******"; service.register(tmpUser, passUser, idUser); service.openStore("adidas", ownerUser); service.createNewProductInStore("milk", "milk", "none", 10, "adidas", ownerUser); products = new List <KeyValuePair <String, int> >(); products.Add(new KeyValuePair <string, int>("milk", 7)); service.addProductsInStore(products, "adidas", ownerUser); productsInCart = new List <KeyValuePair <String, int> >(); productsInCart.Add(new KeyValuePair <string, int>("milk", 10)); }
public void setUp() { DBtransactions db = DBtransactions.getInstance(true); system = new TradingSystem(null, null); user1 = new User(4567, "Yuval", "3399", false, false); system.Users.Add(user1.Id, user1); }
public void TestMethod1_testmethod_failure_remove_basket() { setup(); ShoppingBasket basket = new ShoppingBasket(); DBtransactions.getInstance(true); Assert.AreEqual(false, basket.removeProductsFromCart(null, store.Id, 1)); }
public void TestMethod_failure_edit_basket() { setUp(); ShoppingBasket basket = new ShoppingBasket(); DBtransactions.getInstance(true); Assert.AreEqual(false, basket.editProductQuantityInCart(product.Id, 3, store.Id, -1)); }
public void setUp() { DBtransactions db = DBtransactions.getInstance(true); system = new TradingSystem(null, null); user1 = new User(1234, "Seifan", null, false, false); system.Users.Add(user1.Id, user1); }
public void TestMethod_basket_success_edit() { setUp(); successSetUp(); DBtransactions.getInstance(true); Assert.AreEqual(true, user.Basket.editProductQuantityInCart(product.Id, 3, store.Id, user.Id)); Assert.AreEqual(3, user.Basket.ShoppingCarts[store.Id].Products[product.Id].Quantity); }
public void setup() { DBtransactions db = DBtransactions.getInstance(true); system = new TradingSystem(null, null); user = new User(1, "user", "1234", false, false); store = new Store(1, "store"); product = new Product(1, "product", null, null, -1); }
public void TestMethod1_success_scenario() { setUp(); String userName = "******"; String password = "******"; DBtransactions db = DBtransactions.getInstance(true); Assert.AreEqual(true, service.register(userName, password, id)); service.shutDown(); }
public void TestMethod_basket_success_edit() { setUp(); ShoppingBasket basket = new ShoppingBasket(); ShoppingCart cart = new StubCart2(store.Id, null, true); basket.ShoppingCarts.Add(store.Id, cart); DBtransactions.getInstance(true); Assert.AreEqual(true, basket.editProductQuantityInCart(product.Id, 3, store.Id, -1)); }
public void TestMethod1_success_scenario() { setUp(); DBtransactions db = DBtransactions.getInstance(true); db.isTest(true); String userName = user1.UserName; String password = "******"; int userId = user1.Id; Assert.AreEqual(true, system.register(userName, password, userId)); }
public void testmethod_basket_success_remove() { setup(); productsToRemove = new List <int>(); productsToRemove.Add(product.Id); ShoppingBasket basket = new ShoppingBasket(); ShoppingCart cart = new StubCart(store.Id, null, true); basket.ShoppingCarts.Add(store.Id, cart); DBtransactions.getInstance(true); Assert.AreEqual(true, basket.removeProductsFromCart(productsToRemove, store.Id, -1)); }
public void TestMethod1_success_scenario() { setUp(); DBtransactions db = DBtransactions.getInstance(true); db.isTest(true); StubUser tmpUser = new StubUser(123, "yuval", "4567", false, false, true); String userName = tmpUser.UserName; String password = tmpUser.Password; int userId = tmpUser.Id; system.Users.Add(tmpUser.Id, tmpUser); Assert.AreEqual(true, system.register(userName, password, userId)); }
public void setUp() { DBtransactions.getInstance(true); service = ServiceLayer.getInstance(false); service.register("user", "1234", service.initUser()); service.signIn("admin", "admin"); service.openStore("store", "admin"); service.createNewProductInStore("p1", "", "", 10, "store", "admin"); List <KeyValuePair <string, int> > toInsert = new List <KeyValuePair <string, int> >(); toInsert.Add(new KeyValuePair <string, int>("p1", 100)); service.addProductsInStore(toInsert, "store", "admin"); service.register("manager", "1234", service.initUser()); service.assignManager("manager", "store", new List <string>(), "admin"); }
public void setUp() { service = ServiceLayer.getInstance(false); DBtransactions db = DBtransactions.getInstance(true); db.isTest(true); string owner = service.initUser(); service.register("Rotem", "23&As2", owner); service.signIn("Rotem", "23&As2"); service.openStore("ZARA", "Rotem"); string user = service.initUser(); service.register("Noy", "24!tr4", user); service.signIn("Noy", "24!tr4"); }
public void Setup() { db = DBtransactions.getInstance(false); db.Db = new DBmanager(false); store = new Store(7, "adidas"); admin = new User(14, "guti", "1234", true, true); user = new User(18, "halo", "halo", false, true); p1 = new Product(4, "ramos", "", "", 10); pis1 = new ProductInStore(10, store, p1); store.Products.Add(p1.Id, pis1); manager = new Manager(store, user, new List <int>()); admin.Basket.ShoppingCarts.Add(store.Id, new ShoppingCart(store.Id, store)); pic1 = new ProductInCart(1, admin.Basket.ShoppingCarts[store.Id], p1); admin.Basket.ShoppingCarts[store.Id].Products.Add(p1.Id, pic1); adminOwner = new Owner(store, admin); store.RolesDictionary.Add(admin.Id, store.Roles.AddChild(adminOwner)); admin.Roles.Add(store.Id, adminOwner); }
public void setUp() { service = ServiceLayer.getInstance(false); DBtransactions db = DBtransactions.getInstance(true); db.isTest(true); string owner = service.initUser(); service.register("Rotem", "23&As2", owner); service.signIn("Rotem", "23&As2"); service.openStore("ZARA", "Rotem"); string user = service.initUser(); service.register("Noy", "24!tr4", user); service.signIn("Noy", "24!tr4"); service.createNewProductInStore("Top", "Tank tops", "Light blue", 89, "ZARA", "Rotem"); products = new List <KeyValuePair <String, int> >(); products.Add(new KeyValuePair <string, int>("Top", 7)); service.addProductsInStore(products, "ZARA", "Rotem"); }
public void TestMethod_failure_edit() { setUp(); //failure system edit Assert.AreEqual(false, system.editProductQuantityInCart(product.Id, 3, store.Id, user.Id)); system.Users.Add(user.Id, user); Assert.AreEqual(false, system.editProductQuantityInCart(product.Id, 3, store.Id, user.Id)); system.Users.Remove(user.Id); system.Stores.Add(store.Id, store); Assert.AreEqual(false, system.editProductQuantityInCart(product.Id, 3, store.Id, user.Id)); //failure basket edit DBtransactions.getInstance(true); Assert.AreEqual(false, user.Basket.editProductQuantityInCart(product.Id, 3, store.Id, user.Id)); //failure cart edit user.Basket.ShoppingCarts.Add(store.Id, new ShoppingCart(store.Id, store)); ProductInCart pc = new ProductInCart(2, user.Basket.ShoppingCarts[store.Id], product); user.Basket.ShoppingCarts[store.Id].Products.Add(product.Id, pc); Assert.AreEqual(true, user.Basket.ShoppingCarts[store.Id].editProductQuantityInCart(product.Id, 3)); }
public void TestMethod1_system_successSenrio() { setUp(); DBtransactions.getInstance(true); List <KeyValuePair <int, int> > toInsert = new List <KeyValuePair <int, int> >(); toInsert.Add(new KeyValuePair <int, int>(p1.Id, 1)); toInsert.Add(new KeyValuePair <int, int>(p2.Id, 1)); toInsert.Add(new KeyValuePair <int, int>(p3.Id, 1)); Assert.AreEqual(true, sys.addProductsToCart(toInsert, store.Id, user.Id)); toInsert = new List <KeyValuePair <int, int> >(); toInsert.Add(new KeyValuePair <int, int>(p4.Id, 1)); Assert.AreEqual(true, sys.addProductsToCart(toInsert, store.Id, user.Id)); ShoppingCart cart = sys.Users[user.Id].Basket.ShoppingCarts[store.Id]; Assert.AreEqual(true, cart.Products.ContainsKey(p1.Id)); Assert.AreEqual(true, cart.Products.ContainsKey(p2.Id)); Assert.AreEqual(true, cart.Products.ContainsKey(p3.Id)); Assert.AreEqual(true, cart.Products.ContainsKey(p4.Id)); }