Example #1
0
        public void Store_addSimplePurchasePolicy()
        {
            setUp();
            PurchesPolicyData data = new PurchesPolicyData(0, 0, p1.Id, -1, 2, 10, -1, -1, LogicalConnections.and, null, false);

            try
            {
                ProductConditionPolicy p = (ProductConditionPolicy)store.addSimplePurchasePolicy(data);
                Assert.AreEqual(true, p.getId() == 0, "ProductConditionPolicy- id not insert correctly");
            }
            catch (Exception e)
            {
                Assert.AreEqual(true, false, "ProductConditionPolicy-An object of the wrong type was created");
            }

            data = new PurchesPolicyData(1, 0, p1.Id, -1, 5, -1, -1, -1, LogicalConnections.and, null, false);
            try
            {
                inventoryConditionPolicy p = (inventoryConditionPolicy)store.addSimplePurchasePolicy(data);
                Assert.AreEqual(true, p.getId() == 0, "inventoryConditionPolicy- id not insert correctly");
            }
            catch (Exception e)
            {
                Assert.AreEqual(true, false, "inventoryConditionPolicy-An object of the wrong type was created");
            }
            data = new PurchesPolicyData(2, 0, -1, -1, 2, 10, 15, 30, LogicalConnections.and, null, false);
            try
            {
                BuyConditionPolicy p = (BuyConditionPolicy)store.addSimplePurchasePolicy(data);
                Assert.AreEqual(true, p.getId() == 0, "BuyConditionPolicy- id not insert correctly");
            }
            catch (Exception e)
            {
                Assert.AreEqual(true, false, "BuyConditionPolicy-An object of the wrong type was created");
            }
            data = new PurchesPolicyData(3, 0, -1, -1, -1, -1, -1, -1, LogicalConnections.and, "TelAviv", true);
            try
            {
                UserConditionPolicy p = (UserConditionPolicy)store.addSimplePurchasePolicy(data);
                Assert.AreEqual(true, p.getId() == 0, "UserConditionPolicy- id not insert correctly");
            }
            catch (Exception e)
            {
                Assert.AreEqual(true, false, "UserConditionPolicy-An object of the wrong type was created");
            }
        }
Example #2
0
        public void setup()
        {
            sys         = new TradingSystem(null, null);
            admin       = new User(0, "admin", "1234", true, true);
            admin.State = state.signedIn;
            store       = new Store(0, "store");
            OwnerSotre  = new Owner(store, admin);
            store.RolesDictionary.Add(admin.Id, store.Roles.AddChild(OwnerSotre));
            admin.Roles.Add(store.Id, OwnerSotre);
            manager       = new User(1, "manager", "1234", false, true);
            manager.State = state.signedIn;
            List <int> permmision = new List <int>();

            permmision.Add(2);
            managerSotre = new Manager(store, manager, permmision);
            store.RolesDictionary.Add(manager.Id, store.Roles.AddChild(managerSotre));
            manager.Roles.Add(store.Id, managerSotre);

            p1  = new Product(1, "p1", null, null, 1);
            ps1 = new ProductInStore(10, store, p1);
            store.Products.Add(p1.Id, ps1);
            p2  = new Product(2, "p2", null, null, 10);
            ps2 = new ProductInStore(10, store, p2);
            store.Products.Add(p2.Id, ps2);
            pcp = new ProductConditionPolicy(0, 1, 0, 10, LogicalConnections.and);
            icp = new inventoryConditionPolicy(1, 1, 5, LogicalConnections.and);
            bcp = new BuyConditionPolicy(2, 2, 5, 10, 20, LogicalConnections.and);
            ucp = new UserConditionPolicy(3, "Tel Aviv", true, LogicalConnections.and);
            //itcp= if(buy p1 min buy =0 &max buy =10) then (min inventory =5)
            itcp = new IfThenCondition(4, pcp, icp, LogicalConnections.and);
            lcp  = new LogicalConditionPolicy(5, LogicalConnections.and, LogicalConnections.and);

            sys.Users.Add(admin.Id, admin);
            sys.Users.Add(manager.Id, manager);
            sys.Stores.Add(store.Id, store);
        }