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."); } }
public void PurchasingLimitsTest_PH_ForeignDistributor_Fail() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-PH"); var target = new Ordering.Rules.PurchasingLimits.en_PH.PurchasingLimitRules(); string DsId = "WEBTEST1"; string Local = "en-PH"; var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3)); MembershipUser user = Membership.GetUser(DsId); GenericIdentity identity = new GenericIdentity(user.UserName); RolePrincipal principal = new RolePrincipal(identity); System.Threading.Thread.CurrentPrincipal = principal; HttpContext.Current.User = principal; HttpRuntime.Cache.Insert("DISTR_" + DsId, distributor); var myHlShoppingCart = ShoppingCartProvider.GetShoppingCart(DsId, Local, false); myHlShoppingCart.CurrentItems = new ShoppingCartItemList(); MyHLShoppingCartGenerator.PrepareAddToCart(myHlShoppingCart, ShoppingCartItemHelper.GetCartItem(1, 80, "0065")); var result = target.ProcessCart(myHlShoppingCart, ShoppingCartRuleReason.CartItemsBeingAdded); if (result.Count > 0 && result[0].Messages.Count > 0) { Assert.AreEqual(result[0].Messages[0], "Item SKU:0065 has not been added to the cart since by adding that into the cart, you exceeded your volume points limit."); } else { Assert.Fail("Test Failed"); } }
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 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 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 PurchasingLimitsTest_PH_Distributor() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-PH"); var target = new Ordering.Rules.PurchasingLimits.en_PH.PurchasingLimitRules(); string DsId = "37170799"; string Local = "en-PH"; var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3)); MembershipUser user = Membership.GetUser(DsId); GenericIdentity identity = new GenericIdentity(user.UserName); RolePrincipal principal = new RolePrincipal(identity); System.Threading.Thread.CurrentPrincipal = principal; HttpContext.Current.User = principal; HttpRuntime.Cache.Insert("DISTR_" + DsId, distributor); var myHlShoppingCart = ShoppingCartProvider.GetShoppingCart(DsId, Local, false); myHlShoppingCart.CurrentItems = new ShoppingCartItemList(); MyHLShoppingCartGenerator.PrepareAddToCart(myHlShoppingCart, ShoppingCartItemHelper.GetCartItem(1, 80, "0065")); var result = target.ProcessCart(myHlShoppingCart, ShoppingCartRuleReason.CartItemsBeingAdded); if (result.Count > 0 && result[0].Messages.Count == 0) { Assert.AreEqual(RulesResult.Unknown, result[0].Result); } else { Assert.Fail("Test Failed"); } }
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."); } }
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 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."); } }
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."); } }
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"); } }
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 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."); }
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); }
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; }
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"); }
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 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 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."); }
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); }
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); }
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); }