示例#1
0
        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));
        }
示例#2
0
        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 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 TestMethod1_testmethod_failure_remove_basket()
        {
            setup();
            ShoppingBasket basket = new ShoppingBasket();

            DBtransactions.getInstance(true);
            Assert.AreEqual(false, basket.removeProductsFromCart(null, store.Id, 1));
        }
示例#5
0
        public void setUp()
        {
            DBtransactions db = DBtransactions.getInstance(true);

            system = new TradingSystem(null, null);
            user1  = new User(1234, "Seifan", "2457", false, false);
            system.Users.Add(user1.Id, user1);
        }
        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();
        }
示例#8
0
        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 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));
        }
示例#10
0
        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));
        }
示例#11
0
        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));
        }
示例#12
0
        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");
        }
示例#13
0
        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");
        }
示例#14
0
 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);
 }
示例#15
0
        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");
        }
示例#16
0
        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);

            Assert.AreEqual(1, basket_user.ShoppingCarts.Count);
            Assert.AreEqual(10, basket_user.ShoppingCarts[store.Id].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[store.Id].Products[this.p1.Id].Quantity);
        }
示例#17
0
        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));
        }
示例#18
0
        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));
        }