예제 #1
0
        public static List <ProductAmountPrice> getList()
        {
            int[] amount = { 10, 20, 30, 40 };
            List <ProductAmountPrice> products = new List <ProductAmountPrice>();

            Product[]            p   = new Product[4];
            ProductAmountPrice[] pam = new ProductAmountPrice[4];

            p[0] = new Product("first", 10, "h", "A", 10, 10, 10);
            p[1] = new Product("second", 20, "l", "B", 20, 20, 20);
            p[2] = new Product("third", 30, "k", "B", 30, 30, 30);
            p[3] = new Product("five", 40, "j", "A", 40, 40, 40);

            pam[0] = new ProductAmountPrice(p[0], amount[0], 10);
            pam[1] = new ProductAmountPrice(p[1], amount[1], 20);
            pam[2] = new ProductAmountPrice(p[2], amount[2], 30);
            pam[3] = new ProductAmountPrice(p[3], amount[3], 40);

            products.Add(pam[0]);
            products.Add(pam[1]);
            products.Add(pam[2]);
            products.Add(pam[3]);

            return(products);
        }
예제 #2
0
        public override List <ProductAmountPrice> Apply(List <ProductAmountPrice> products, User user)
        {
            Product            product     = WorkShop.findProduct(productId).Values.First();
            ProductAmountPrice freeProduct = new ProductAmountPrice(product, amount, 0);

            products.Add(freeProduct);
            return(products);
        }
예제 #3
0
 public override void Copy(IEntity other)
 {
     base.Copy(other);
     if (other is ProductAmountPrice)
     {
         ProductAmountPrice _other = ((ProductAmountPrice)other);
         product = _other.product;
     }
 }
예제 #4
0
        public void translateCartTest()
        {
            List <ProductAmountPrice> list = ProductAmountPrice.translateCart(shoppingCart);

            Assert.AreEqual(list.Count, shoppingCart.getProducts().Count);

            foreach (ProductAmountPrice item in list)
            {
                Assert.IsNotNull(shoppingCart.getProduct(item.product.id));
                Assert.AreEqual(item.amount, shoppingCart.getProductAmount(item.product));
            }
        }
예제 #5
0
        public static List <ProductAmountPrice> translateCart(ShoppingCart cart)
        {
            List <ProductAmountPrice> output   = new List <ProductAmountPrice>();
            List <ProductAmount>      products = cart.getProducts();

            foreach (ProductAmount p in products)
            {
                ProductAmountPrice newProduct = new ProductAmountPrice(p.product, p.amount, p.product.price);
                output.Add(newProduct);
            }
            return(output);
        }
예제 #6
0
        public void Init()
        {
            p[0] = new Product("first", 10, "h", "g", 10, 10, 10);
            p[1] = new Product("second", 20, "l", "g", 20, 20, 20);
            p[2] = new Product("third", 30, "k", "g", 30, 30, 30);
            p[3] = new Product("five", 40, "j", "g", 40, 40, 40);

            shoppingCart.addProducts(p[1], amount[0]);
            shoppingCart.addProducts(p[2], amount[1]);
            shoppingCart.addProducts(p[3], amount[2]);
            shoppingCart.addProducts(p[3], amount[3]);

            pam[0] = new ProductAmountPrice(p[0], amount[0], 10);
            pam[1] = new ProductAmountPrice(p[1], amount[1], 20);
            pam[2] = new ProductAmountPrice(p[2], amount[2], 30);
            pam[3] = new ProductAmountPrice(p[3], amount[3], 40);

            products.Add(pam[0]);
            products.Add(pam[1]);
            products.Add(pam[2]);
            products.Add(pam[3]);
        }
 public void Init()
 {
     p   = new Product("first", 10, "h", "g", 10, 10, 10);
     pam = new ProductAmountPrice(p, amount, 10);
     list.Add(pam);
 }
예제 #8
0
        public void sumProduct()
        {
            int listSum = ProductAmountPrice.sumProduct(products);

            Assert.AreEqual(100, listSum);
        }