public void ProcessCartTest_Global_Fail()
        {
            var testSettings = new OrderingTestSettings("en-US", "1111111111");
            var target       = new Ordering.Rules.SKULimitations.Global.SKULimitationsRules();

            var usCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor,
                testSettings.Locale,
                null,
                null,
                false,
                null,
                new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetShoppingCartItem(1, 1, "S203"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 1, "3107"),
            },
                OrderCategoryType.ETO);

            var totalItems = usCart.CartItems.Count;

            target.ProcessCart(usCart, ShoppingCartRuleReason.CartRetrieved);
            Assert.AreEqual(
                totalItems,
                usCart.ShoppingCartItems.Count(),
                "you can not add TodayMagazine SKUs,Otherwise this will be deleted from your cart.");
        }
Example #2
0
        public void PromotionalRules_ProcessCartTest_IT_Aloe_CartItemsRemoved_PromoEneded()
        {
            var settings     = new OrderingTestSettings("it-IT", "1111111111");
            var promoAloeSku = HLConfigManager.CurrentPlatformConfigs[settings.Locale].ShoppingCartConfiguration.PromotionalSku = "0141";
            var endDate      = HLConfigManager.CurrentPlatformConfigs[settings.Locale].ShoppingCartConfiguration.PromotionalEndDate = "2013-06-26";

            var skus = new List <string> {
                "2561", "2562"
            };
            var itCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(settings.Distributor, settings.Locale, null, null, false, null,
                                                                        ShoppingCartItemHelper.GetDistributorShoppingCartItemList(settings.Locale, skus, skus.Count, 10),
                                                                        OrderCategoryType.RSO);

            var target = new Ordering.Rules.Promotional.it_IT.PromotionalRulesAloe();

            target.ProcessCart(itCart, ShoppingCartRuleReason.CartItemsRemoved);
            var ruleResult = itCart.RuleResults.FirstOrDefault(r => r.RuleName.Equals("Promotional Rules"));

            if (ruleResult != null && ruleResult.Result == RulesResult.Feedback)
            {
                Assert.IsNull(itCart.CartItems.FirstOrDefault(c => c.SKU.Equals(promoAloeSku)), "There is not promo sku in catalog items");
                return;
            }
            Assert.AreEqual(true, ruleResult != null && ruleResult.Messages.Any(m => m.Equals("PromoOutOfDate")));
        }
        public void ExceedGroupLimitAndIndivualLimit_TestMethod()
        {
            var cartItems = new ShoppingCartItemList();

            cartItems.Add(new ShoppingCartItem_V01 {
                SKU = "0120", Quantity = 9
            });

            var cartItemsBeingAdded = new ShoppingCartItemList();

            cartItemsBeingAdded.Add(new ShoppingCartItem_V01 {
                SKU = "0120", Quantity = 1
            });                                                                               // FO
            cartItemsBeingAdded.Add(new ShoppingCartItem_V01 {
                SKU = "0118", Quantity = 91
            });                                                                                // FO
            cartItemsBeingAdded.Add(new ShoppingCartItem_V01 {
                SKU = "1158", Quantity = 11
            });                                                                                // NFO

            MyHLShoppingCart cart =
                MyHLShoppingCartGenerator.GetBasicShoppingCart("staff", "ja-JP", "30", "SAG",
                                                               cartItems, OrderCategoryType.RSO);

            cart.ItemsBeingAdded = cartItemsBeingAdded;

            MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules rules = new MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules();
            rules.HandleCartItemsBeingAdded(cart, new ShoppingCartRuleResult(), MockPurchaseRestrictionInfo());
        }
        public void ProcessCartTestGlobal_InvalidQuantities_Fail()
        {
            var testSettings = new OrderingTestSettings("en-IN", "1111111111");
            var target       = new Ordering.Rules.CartIntegrity.Global.CartIntegrityRules();

            var distributor = OnlineDistributorHelper.GetOnlineDistributor(testSettings.Distributor);

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor, testSettings.Locale, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, -1, "1248", testSettings.Locale),
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "1247", testSettings.Locale)
            }, OrderCategoryType.ETO);

            cart.ShoppingCartID = 1;

            var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartCalculated);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "Invalid sku quantity found. DS: 1111111111, CART: 1, SKU 1248 : quantity updated to 1.");
            }
            else
            {
                Assert.Fail("The Sku quantity -1 should be updated to 1.");
            }
        }
Example #5
0
        public void ProcessCartTest()
        {
            const string DsId         = "090245813";
            const string Local        = "en-US";
            var          testSettings = new OrderingTestSettings(Local, DsId);
            var          target       = new Ordering.Rules.EventTicket.Global.EventTicketRules();
            var          distributor  =
                OnlineDistributorHelper.GetOnlineDistributor(testSettings.Distributor);

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "D077", Local)
            }, OrderCategoryType.RSO);

            cart.ShoppingCartID = 1;
            var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartItemsBeingAdded);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual((string)result[0].Messages[0],
                                "The sku D077 is not valid.");
            }
            else
            {
                Assert.Fail("Distributor can not add the Sku D077 when oreder catagory is Non Event Ticket Ordering");
            }
        }
Example #6
0
        public void PerformBackorderRules_Inventory_pt_BR()
        {
            var testSettings = new OrderingTestSettings("pt-BR", "webtest1");
            var target       = new Ordering.Rules.Inventory.pt_BR.InventoryRules();

            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor, testSettings.Locale, "RSP", "BM", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetShoppingCartItem(1, 1, "0141")
            }, OrderCategoryType.RSO);
            CatalogItem item = CatalogProvider.GetCatalogItem("0141", "BR");
            int         PreviousItemsCount = cart.CartItems.Count();

            target.PerformBackorderRules(cart, item);
            int NowItemsCount = cart.CartItems.Count();

            if (!cart.RuleResults.Any())
            {
                Assert.AreEqual(PreviousItemsCount, NowItemsCount);
            }
            else if (cart.RuleResults.Any() && cart.RuleResults[0].Messages.Count > 0)
            {
                Assert.AreEqual(RulesResult.Failure, cart.RuleResults[0].Result);
            }
        }
        public void SKU0106_OverLimit_TestMethod1()
        {
            var cartItems = new ShoppingCartItemList();

            cartItems.Add(new ShoppingCartItem_V01 {
                SKU = "0120", Quantity = 1
            });
            cartItems.Add(new ShoppingCartItem_V01 {
                SKU = "0106", Quantity = 6
            });                                                                     //NFO

            var cartItemsBeingAdded = new ShoppingCartItemList();

            cartItemsBeingAdded.Add(new ShoppingCartItem_V01 {
                SKU = "0106", Quantity = 4
            });

            MyHLShoppingCart cart =
                MyHLShoppingCartGenerator.GetBasicShoppingCart("staff", "ja-JP", "XX", "XX",
                                                               cartItems, OrderCategoryType.RSO);

            cart.ItemsBeingAdded = cartItemsBeingAdded;

            MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules rules = new MyHerbalife3.Ordering.Rules.PurchaseRestriction.JP.PurchaseRestrictionRules();
            rules.HandleCartItemsBeingAdded(cart, new ShoppingCartRuleResult(), MockPurchaseRestrictionInfo());
        }
        public void ProcessCartTesten_US_CheckForHFFSKU_Fail()
        {
            const string DsId         = "1111111111";
            const string Local        = "en-US";
            var          testSettings = new OrderingTestSettings(Local, DsId);
            var          target       = new Ordering.Rules.CartIntegrity.en_US.CartIntegrityRules();

            var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "F356", Local)
            }, OrderCategoryType.ETO);

            var result = target.ProcessCart(
                cart, ShoppingCartRuleReason.CartWarehouseCodeChanged);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "Invalid sku found. DS: 1111111111, CART: 0, SKU F356 : removed from cart.");
            }
            else
            {
                Assert.Fail("Distributor can not add HFF Sku F356.");
            }
        }
        public void ProcessCartTestGlobal_DuplicateSKUs_Fail()
        {
            string DsId         = "1111111111";
            string Local        = "en-IN";
            var    testSettings = new OrderingTestSettings(Local, DsId);
            var    target       = new Ordering.Rules.CartIntegrity.Global.CartIntegrityRules();

            var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "1248", Local),
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "1248", Local)
            }, OrderCategoryType.ETO);

            var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartCalculated);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "Duplicate sku found. DS: 1111111111, CART: 0, SKU 1248 removed from cart.");
            }
            else
            {
                Assert.Fail("SKU 1248 is dupliacte.it should be removed from the cart");
            }
        }
        public void ProcessCartTestNonWebClient_Invalidquantity_Fail()
        {
            const string DsId         = "1111111111";
            const string Local        = "en-AU";
            var          testSettings = new OrderingTestSettings(Local, DsId);
            var          target       = new Ordering.Rules.CartIntegrity.NonWebClient.CartIntegrityRules();

            var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 200, "0124", Local)
            }, OrderCategoryType.ETO);

            cart.ShoppingCartID = 1;

            var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartItemsBeingAdded);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "The quantity of SKU 0124 is not valid.");
            }
            else
            {
                Assert.Fail("May be the quantity 200 for the sku 0124 is valid for Australia.");
            }
        }
Example #11
0
        public void CanPurchase_With_Brazil_DS_ZeroVolume()
        {
            var             testSettings = new OrderingTestSettings("es-AR", "WEBTESTBR");
            var             ruleEngine   = new Ordering.Rules.PurchasingPermissions.es_AR.PurchasingPermissionRules();
            MembershipUser  user         = Membership.GetUser(testSettings.Distributor);
            GenericIdentity identity     = new GenericIdentity(user.UserName);
            RolePrincipal   principal    = new RolePrincipal(identity);

            System.Threading.Thread.CurrentPrincipal = principal;
            HttpContext.Current.User = principal;
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor, testSettings.Locale, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 5, "5451", testSettings.Locale)
            }, OrderCategoryType.ETO);

            cart.ShoppingCartID = 1;
            var result = ruleEngine.ProcessCart(cart, ShoppingCartRuleReason.CartItemsBeingAdded);

            if (result.Count > 0 && result[0].Messages.Count == 0)
            {
                Assert.AreEqual(0,
                                result[0].Messages.Count);
            }
            else
            {
                Assert.Fail("May be the volume poient of sku 5451 is not 0.");
            }
        }
Example #12
0
        public void ProcessCartTest()
        {
            var testSettings = new OrderingTestSettings("ru-RU", "79039381");
            var target       = new RulesEngine.APF.Global.APFRules();

            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor, testSettings.Locale, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "1248", testSettings.Locale)
            }, OrderCategoryType.RSO);

            MyHLShoppingCartGenerator.PrepareAddToCart(cart, ShoppingCartItemHelper.GetCartItem(1, 1, "1248"));
            cart.ShoppingCartID = 1;

            List <ShoppingCartRuleResult> result = target.ProcessCart(
                cart, ShoppingCartRuleReason.CartItemsBeingAdded);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(
                    RulesResult.Failure,
                    result[0].Result,
                    "Please complete your annual fee purchase before adding other products to cart.");
            }
            else
            {
                Assert.Fail("May be APF is not due for this Distributor.");
            }
        }
Example #13
0
        public void PromotionalRules_ProcessCartTest_SG_CartItemsAdded_AddingPromoZ479()
        {
            var locale        = "en-SG";
            var distributorId = "1111111111";
            var skus          = new List <string> {
                "0141", "Z478"
            };
            var promoSku = "Z479";

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(locale);
            var sgCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(distributorId, locale, null, null, false, null,
                                                                        ShoppingCartItemHelper.GetDistributorShoppingCartItemList(locale, skus, skus.Count, 1),
                                                                        OrderCategoryType.RSO);
            var target     = new Ordering.Rules.Promotional.en_SG.PromotionalRules();
            var ruleResult = target.ProcessCart(sgCart, ShoppingCartRuleReason.CartItemsAdded).FirstOrDefault(r => r.RuleName.Equals("Promotional Rules"));

            if (ruleResult != null && ruleResult.Result == RulesResult.Feedback)
            {
                var message = string.Format(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform),
                                                                                "NoPromoSku").ToString(), "SG", "Z479");
                Assert.AreEqual(true, ruleResult != null && ruleResult.Messages.Any(m => m.Equals(message)));
                return;
            }
            Assert.AreEqual(true, ruleResult != null && ruleResult.Result == RulesResult.Success);
        }
        public void PerformOrderManagementRules()
        {
            const string Distributor = "06304245";
            const string Locale      = "th-TH";
            var          cart        = MyHLShoppingCartGenerator.GetBasicShoppingCart(Distributor, Locale);
            Order_V01    order       = OrderHelper.GetOrder(Locale, Distributor);

            order.OrderMonth = "5607";
            var ruleEngine = new Ordering.Rules.OrderManagement.th_TH.OrderManagementRules();

            // Getting a result.
            ruleEngine.PerformOrderManagementRules(cart, order, Locale, OrderManagementRuleReason.Unknown);
            // Asserts.
            Assert.AreEqual("1307", order.OrderMonth, "Order Management Rule from TH is not working");
        }
Example #15
0
        public void PerformDiscountRangeRules_BrWithDiscount50()
        {
            // Used constants.
            const string Distributor = "09550499";
            const string Locale      = "pt-BR";

            // Getting a shopping cart for BR.
            var brazilShoppingCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(Distributor, Locale);
            var ruleEngine         = new Ordering.Rules.Discount.pt_BR.DiscountRules();

            // Getting a result.
            var result = ruleEngine.PerformDiscountRangeRules(brazilShoppingCart, Locale, 50.0M);

            // Asserts.
            Assert.AreEqual(result, string.Empty, "Discount range should be empty for a DS with 50% of discount.");
        }
Example #16
0
        public void AdditionalInfoHelper_StaffUSLocale_SKUNotFound()
        {
            // Arrange
            int    id       = 0;
            int    quantity = 1;
            string sku      = "QQQQ";

            var shoppingCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(distributorStaff, locale_enUS);
            var cartItem     = ShoppingCartItemHelper.GetShoppingCartItem(id, quantity, sku);

            // Act
            shoppingCart.AdditionalInfoHelper(locale_enUS, cartItem);

            // Assert
            Assert.IsNull(cartItem.ParentCat, "Test failed with values: distributorid-{0}, locale-{1}, sku-{2}",
                          distributorStaff, locale_enUS, sku);
        }
Example #17
0
        public void PromotionalRules_ProcessCartTest_IT_Aloe_CartItemsBeingRemoved_PromoSku()
        {
            var settings     = new OrderingTestSettings("it-IT", "1111111111");
            var promoAloeSku = HLConfigManager.CurrentPlatformConfigs[settings.Locale].ShoppingCartConfiguration.PromotionalSku;
            var skus         = new List <string> {
                "0118", "2561", "2562", promoAloeSku
            };
            var itCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(settings.Distributor, settings.Locale, null, null, false, null,
                                                                        ShoppingCartItemHelper.GetDistributorShoppingCartItemList(settings.Locale, skus, skus.Count, 1),
                                                                        OrderCategoryType.RSO);

            MyHLShoppingCartGenerator.PrepareAddToCart(itCart, ShoppingCartItemHelper.GetCartItem(1, 1, promoAloeSku));

            var target = new Ordering.Rules.Promotional.it_IT.PromotionalRulesAloe();

            target.ProcessCart(itCart, ShoppingCartRuleReason.CartItemsBeingRemoved);
            Assert.IsNotNull(itCart.CartItems.Any(c => c.SKU.Equals(promoAloeSku)));
        }
        public void ProcessDonation_Test()
        {
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("CN640521", "zh-CN", "3", "888",
                                                                      new ShippingAddress_V02());

            cart.CartItems = new ShoppingCartItemList
            {
                ShoppingCartItemHelper.GetCartItem(1, 1, "1316"),
            };

            var order = new Order_V01();

            order.DistributorID = "CN640521";

            var orderitem1 = new OnlineOrderItem()
            {
                Quantity    = 1,
                SKU         = "1316",
                Description = "Test",
                RetailPrice = 0,
                IsPromo     = false,
            };

            MyHerbalife3.Ordering.Providers.Shipping.DeliveryOption deliveryOption = new MyHerbalife3.Ordering.Providers.Shipping.DeliveryOption();
            order.CountryOfProcessing = "CN";
            order.OrderItems          = new OrderItems {
                orderitem1
            };
            order.Shipment = new ShippingInfo_V01
            {
                Address = new MyHerbalife3.Ordering.ServiceProvider.OrderSvc.Address
                {
                    City    = "眉山市",
                    Country = "cn"
                },
                ShippingMethodID = "22",
                WarehouseCode    = "888"
            };

            var ordertotal = new OrderTotals_V02();

            GetQuotes(order, ordertotal, false, out ordertotal);
            cart.Totals = ordertotal;
        }
Example #19
0
        public void PromotionalRules_ProcessCartTest_SG_PromoEnded()
        {
            var locale        = "en-SG";
            var distributorId = "1111111111";

            HLConfigManager.Configurations.ShoppingCartConfiguration.PromotionalEndDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
            var skus = new List <string> {
                "2561", "2562"
            };
            var sgCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(distributorId, locale, null, null, false, null,
                                                                        ShoppingCartItemHelper.GetDistributorShoppingCartItemList(locale, skus, skus.Count, 1),
                                                                        OrderCategoryType.RSO);
            var target = new Ordering.Rules.Promotional.en_SG.PromotionalRules();

            MyHLShoppingCartGenerator.PrepareAddToCart(sgCart, ShoppingCartItemHelper.GetCartItem(1, 1, "2561"));
            var ruleResult = target.ProcessCart(sgCart, ShoppingCartRuleReason.CartItemsAdded).FirstOrDefault(r => r.RuleName.Equals("Promotional Rules"));

            Assert.AreEqual(true, ruleResult != null && ruleResult.Result == RulesResult.Unknown);
        }
        public void PerformRulesTest_Nicaragua_Fail()
        {
            var testSettings = new OrderingTestSettings("es-NI", "1111111111");
            var target       = new Ordering.Rules.SKULimitations.SamCam.SKULimitationsRules();

            var myHlShoppingCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor,
                testSettings.Locale,
                null,
                null,
                false,
                null,
                new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetShoppingCartItem(1, 16, "2512"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0142"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0143"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0146"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "2638"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0242"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0105"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0106"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0102"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "2864"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "6240"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "6926"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "8602"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "8601"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "5451"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "7123"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0865"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "2514")
            },
                OrderCategoryType.RSO);

            // Adding a new item.
            MyHLShoppingCartGenerator.PrepareAddToCart(myHlShoppingCart, ShoppingCartItemHelper.GetCartItem(1, 16, "2511"));

            target.ProcessCart(myHlShoppingCart, ShoppingCartRuleReason.CartItemsBeingAdded);

            Assert.IsTrue(myHlShoppingCart.RuleResults.Count > 0, "Max NTS lines for Nicaragua should by 18");
        }
Example #21
0
        public void ProcessCartTest_Italy_CartItemsRemoved()
        {
            // Used constants.
            const string Distributor = "25657863";
            const string Locale      = "it-IT";
            // Getting a shopping cart for IT.
            var shoppingCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(Distributor, Locale, "FREIGHT", null, false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 10, PromoU688, Locale)
            }, OrderCategoryType.RSO);
            var ruleEngine = new Ordering.Rules.Promotional.it_IT.PromotionalRules();

            shoppingCart.RuleResults = new List <ShoppingCartRuleResult>();
            // Getting a result.
            var result = ruleEngine.ProcessCart(
                shoppingCart, ShoppingCartRuleReason.CartItemsRemoved);

            // Asserts.
            Assert.IsNotNull(result, "Cart Processed as Cart Items Being Removed");
        }
        public void ProcessCartTest_SamCam_Fail()
        {
            var testSettings = new OrderingTestSettings("es-SV", "1111111111");
            var target       = new Ordering.Rules.SKULimitations.SamCam.SKULimitationsRules();

            var myHlShoppingCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor,
                testSettings.Locale,
                null,
                null,
                false,
                null,
                new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetShoppingCartItem(1, 15, "0141"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0142"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0143"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0146"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "2638"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0242"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0105"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0106"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0006"),
                ShoppingCartItemHelper.GetShoppingCartItem(1, 10, "0065"),
            },
                OrderCategoryType.ETO);

            // Adding a new item.
            MyHLShoppingCartGenerator.PrepareAddToCart(myHlShoppingCart, ShoppingCartItemHelper.GetCartItem(1, 15, "0122"));

            var totalItems = myHlShoppingCart.CartItems.Count;

            target.ProcessCart(myHlShoppingCart, ShoppingCartRuleReason.CartItemsBeingAdded);

            Assert.AreEqual(
                totalItems,
                myHlShoppingCart.ShoppingCartItems.Count,
                "you can not add TodayMagazine SKUs,Otherwise this will be deleted from your cart.");
        }
Example #23
0
        public void InventoryRules_Global_AvailableForBackOrder_Shipping_LorAType_Test_Passed()
        {
            var testSettings = new OrderingTestSettings("en-US", "webtest1");
            var target       = new Ordering.Rules.Inventory.Global.InventoryRules();

            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor, testSettings.Locale, "", "BK", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetShoppingCartItem(1, 1, "5918")
            }, OrderCategoryType.ETO);

            var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartItemsAdded);

            if (result.Any() && result[0].Messages.Count == 0)
            {
                Assert.AreEqual(RulesResult.Unknown, result[0].Result);
            }
            else if (result.Any() && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(RulesResult.Failure, result[0].Result);
            }
        }
        public void SKULimitationsRules_ProcessCartTest_HN_Fail()
        {
            var settings = new OrderingTestSettings("es-HN", "1111111111");

            // Maximum sku number for HN should be 10
            var skus = new List <string> {
                "0141", "0142", "0143", "0146", "2638", "0242", "2864", "0105", "0106", "0006", "0065", "3150"
            };
            var linesInShoppingCart = 10;
            var qty    = 5;
            var target = new Ordering.Rules.SKULimitations.SamCam.SKULimitationsRules();

            var hnCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(settings.Distributor, settings.Locale, null, null, false, null,
                                                                        ShoppingCartItemHelper.GetDistributorShoppingCartItemList(settings.Locale, skus, linesInShoppingCart, qty),
                                                                        OrderCategoryType.RSO);

            MyHLShoppingCartGenerator.PrepareAddToCart(hnCart, ShoppingCartItemHelper.GetCartItem(1, 1, "0102"));

            target.ProcessCart(hnCart, ShoppingCartRuleReason.CartItemsBeingAdded);
            var ruleResult = hnCart.RuleResults.Where(r => r.RuleName.Equals("SkuLimitation Rules")).FirstOrDefault();
            var failed     = ruleResult != null && ruleResult.Result == RulesResult.Failure;

            Assert.AreEqual(true, failed);
        }
Example #25
0
        public void PerformDiscountRangeRules_BrWithDiscount35VP500()
        {
            // Used constants.
            const string Distributor = "09550499";
            const string Locale      = "pt-BR";

            // Getting a shopping cart for BR.
            var brazilShoppingCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                Distributor,
                Locale,
                new OrderTotals_V01
            {
                VolumePoints       = 500M,
                DiscountPercentage = 35M
            });
            var ruleEngine = new Ordering.Rules.Discount.pt_BR.DiscountRules();

            // Getting a result.
            var result = ruleEngine.PerformDiscountRangeRules(brazilShoppingCart, Locale, 35.0M);

            // Asserts.
            Assert.AreEqual(result, "500-999",
                            "Discount range should be 500-999 for a DS with 35% of discount and VP < 1000.");
        }
        public void ProcessVolumePromotionDSNovPromo_Test()
        {
            var promoelement = new PromotionElement
            {
                StartDate            = "11-01-2015",
                EndDate              = "11-30-2015",
                PromotionType        = MyHerbalife3.Ordering.ServiceProvider.OrderChinaSvc.PromotionType.Volume,
                HasIncrementaldegree = true,
                VolumeMinInclude     = 200,
                CustTypeList         = new List <string>
                {
                    "DS", "FM", "SC", "SP", "SQ"
                },
                FreeSKUList = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "1443"
                    },
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "K365"
                    },
                },
                SelectableSKUList = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "1316"
                    },
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "1318"
                    },
                },
                FreeSKUListForVolume = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "1443"
                    },
                },
                FreeSKUListForSelectableSku = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "K365"
                    },
                },
            };

            promoelement.Code = "DSNovPromo";
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("CN640521", "zh-CN", "20", "3019",
                                                                      new ShippingAddress_V02());

            cart.CartItems = new ShoppingCartItemList
            {
                ShoppingCartItemHelper.GetCartItem(1, 1, "1316"),
                ShoppingCartItemHelper.GetCartItem(2, 1, "1442"),
                ShoppingCartItemHelper.GetCartItem(3, 1, "1318")
            };
            var order = new Order_V01();

            order.DistributorID = "CN640521";
            var orderitem1 = new OnlineOrderItem()
            {
                Quantity    = 10,
                SKU         = "1316",
                Description = "",
                RetailPrice = 0,
                IsPromo     = false,
            };
            var orderitem2 = new OnlineOrderItem()
            {
                Quantity    = 1,
                SKU         = "1442",
                Description = "",
                RetailPrice = 0,
                IsPromo     = false,
            };
            var orderitem3 = new OnlineOrderItem()
            {
                Quantity    = 1,
                SKU         = "1318",
                Description = "",
                RetailPrice = 0,
                IsPromo     = false,
            };

            order.OrderItems = new OrderItems {
                orderitem1, orderitem2, orderitem3
            };
            order.Shipment = new ShippingInfo_V01
            {
                Address = new MyHerbalife3.Ordering.ServiceProvider.OrderSvc.Address
                {
                    City    = "眉山市",
                    Country = "cn"
                },
                ShippingMethodID = "22",
                WarehouseCode    = "3019"
            };
            order.CountryOfProcessing = "CN";
            var ordertotal = new MyHerbalife3.Ordering.ServiceProvider.OrderSvc.OrderTotals_V02();

            GetQuotes(order, ordertotal, false, out ordertotal);
            var promorule = new MyHerbalife3.Ordering.Rules.Promotional.zh_CN.PromotionalRules();

            cart.Totals = ordertotal;
            FreeSKUCollection skuCollection = promorule.CheckDsNovPromo(promoelement, cart);

            Assert.AreEqual(skuCollection[0].Quantity, 3);
        }
        public void ProcessOtherMarchPromotionPC_Test()
        {
            var Promotion = new PromotionElement
            {
                StartDate            = "01-01-2016",
                EndDate              = "01-31-2016",
                PromotionType        = ServiceProvider.OrderChinaSvc.PromotionType.Other,
                HasIncrementaldegree = true,
                AmountMinInclude     = 2000,
                CustTypeList         = new List <string>
                {
                    "PC", "CS"
                },
                FreeSKUList = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "560P"
                    }
                },
            };

            Promotion.Code = "00017";
            var Cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("CN1632369 ", "zh-CN", "20", "3019",
                                                                      new ShippingAddress_V02());

            Cart.CartItems = new ShoppingCartItemList
            {
                ShoppingCartItemHelper.GetCartItem(1, 1, "1316"),
                ShoppingCartItemHelper.GetCartItem(2, 1, "1317"),
            };

            var Order = new Order_V01();

            Order.DistributorID = "CN1632369";
            var order1 = new OnlineOrderItem()
            {
                Quantity    = 10,
                SKU         = "1316",
                Description = "",
                RetailPrice = 0,
                IsPromo     = false,
            };

            Order.OrderItems = new OrderItems {
                order1
            };
            Order.Shipment = new ShippingInfo_V01
            {
                Address = new ServiceProvider.OrderSvc.Address()
                {
                    City    = "眉山市",
                    Country = "cn"
                },
                ShippingMethodID = "22",
                WarehouseCode    = "3019"
            };

            Order.CountryOfProcessing = "CN";
            var ordertotal = new OrderTotals_V02();

            GetQuotes(Order, ordertotal, false, out ordertotal);
            var promorule = new MyHerbalife3.Ordering.Rules.Promotional.zh_CN.PromotionalRules();

            Cart.Totals = ordertotal;
            FreeSKUCollection skuCollection = promorule.CheckPcPromo(Promotion, Cart);

            Assert.AreEqual(skuCollection[0].Quantity, 2);
        }