public void setUp() { 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", "", "", 5000); p2 = new Product(1, "second", "", "", 5000); p3 = new Product(2, "third", "", "", 5000); p4 = new Product(3, "fourth", "", "", 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); Dictionary <int, KeyValuePair <ProductInStore, int> > discountProduct = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); discountProduct.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis1, 0)); rd_min = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.2, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); rd_mid = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.25, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); rd_max = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.3, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); rd_mid_without = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.35, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithoutMultiplication); rd_max_without = new RevealedDiscount(sys.DiscountPolicyCounter++, 1, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithoutMultiplication); Dictionary <int, KeyValuePair <ProductInStore, int> > relatedProduct = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); relatedProduct.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis1, 2)); lc1 = new LeafCondition(relatedProduct, 0, 0, null, new DateTime(), DuplicatePolicy.WithMultiplication); relatedProduct = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); relatedProduct.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis2, 1)); lc2 = new LeafCondition(relatedProduct, 0, 0, null, new DateTime(), DuplicatePolicy.WithMultiplication); Dictionary <int, ProductInStore> ProductPrecentage = new Dictionary <int, ProductInStore>(); ProductPrecentage.Add(pis1.Product.Id, pis1); ProductPrecentage.Add(pis2.Product.Id, pis2); lc = new LogicalCondition(0, 0.5, ProductPrecentage, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication, LogicalConnections.and); lc.addChild(0, lc1); lc.addChild(1, lc2); }
public void sutup() { p1 = new Product(0, "p1", null, null, 20); store = new Store(7, "a"); pis1 = new ProductInStore(20, store, p1); p2 = new Product(1, "p2", null, null, 20); pis2 = new ProductInStore(20, store, p2); Dictionary <int, KeyValuePair <ProductInStore, int> > productList = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); productList.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis1, 1)); rd = new RevealedDiscount(1, 0.5, productList, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); Dictionary <int, KeyValuePair <ProductInStore, int> > relatedProducts = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); relatedProducts.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis1, 1)); relatedProducts.Add(p2.Id, new KeyValuePair <ProductInStore, int>(pis2, 2)); Dictionary <int, ProductInStore> discountproducts = new Dictionary <int, ProductInStore>(); discountproducts.Add(p1.Id, pis1); discountproducts.Add(p2.Id, pis2); lc = new LeafCondition(relatedProducts, 10, 0.5, discountproducts, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); relatedProducts = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); relatedProducts.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis1, 1)); lc1 = new LeafCondition(relatedProducts, 10, 0.5, discountproducts, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); relatedProducts = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); relatedProducts.Add(p2.Id, new KeyValuePair <ProductInStore, int>(pis2, 2)); lc2 = new LeafCondition(relatedProducts, 10, 0.5, discountproducts, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); logcAnd = new LogicalCondition(10, 0.5, discountproducts, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication, LogicalConnections.and); logcAnd.addChild(0, lc1); logcAnd.addChild(1, lc2); logcOr = new LogicalCondition(10, 0.5, discountproducts, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication, LogicalConnections.or); logcOr.addChild(0, lc1); logcOr.addChild(1, lc2); logcXor = new LogicalCondition(10, 0.5, discountproducts, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication, LogicalConnections.xor); logcXor.addChild(0, lc1); logcXor.addChild(1, lc2); }