public void OrderService_CanUpdateShippingMethod() { var app = BaseTest.CreateHccAppInMemory(); app.CurrentRequestContext.CurrentStore = new Store(); app.CurrentRequestContext.CurrentStore.Id = 230; var target = new ShippingMethod(); target.Adjustment = 1.23m; target.AdjustmentType = ShippingMethodAdjustmentType.Percentage; target.Bvin = string.Empty; target.Name = "Test Name"; target.Settings.AddOrUpdate("MySetting", "MySetVal"); target.ShippingProviderId = "123456"; target.ZoneId = -101; app.OrderServices.ShippingMethods.Create(target); Assert.AreNotEqual(string.Empty, target.Bvin, "Bvin should not be empty"); target.Adjustment = 1.95m; target.AdjustmentType = ShippingMethodAdjustmentType.Amount; target.Name = "Test Name Updated"; target.Settings.AddOrUpdate("MySetting", "MySetVal 2"); target.ShippingProviderId = "1Update"; target.ZoneId = -100; Assert.IsTrue(app.OrderServices.ShippingMethods.Update(target)); var actual = app.OrderServices.ShippingMethods.Find(target.Bvin); Assert.IsNotNull(actual, "Actual should not be null"); Assert.AreEqual(actual.Adjustment, target.Adjustment); Assert.AreEqual(actual.AdjustmentType, target.AdjustmentType); Assert.AreEqual(actual.Bvin, target.Bvin); Assert.AreEqual(actual.Name, target.Name); Assert.AreEqual(actual.Settings["MySetting"], target.Settings["MySetting"]); Assert.AreEqual(actual.ShippingProviderId, target.ShippingProviderId); Assert.AreEqual(actual.ZoneId, target.ZoneId); }
public void Option_CanAddOptionsToProductInCorrectOrder() { var app = BaseTest.CreateHccAppInMemory(); app.CurrentRequestContext.CurrentStore = new Store(); app.CurrentRequestContext.CurrentStore.Id = 342; var p = new Product(); p.Sku = "TESTABC"; p.ProductName = "Test Product ABC"; var opt = new Option(); opt.SetProcessor(OptionTypes.CheckBoxes); opt.Name = "Test Option A"; opt.Items.Add(new OptionItem { Name = "Item A" }); opt.Items.Add(new OptionItem { Name = "Item B" }); var opt2 = new Option(); opt.SetProcessor(OptionTypes.DropDownList); opt.Items.Add(new OptionItem { Name = "Choice One" }); opt.Items.Add(new OptionItem { Name = "Choice Two" }); var opt3 = Option.Factory(OptionTypes.Html); opt3.Name = "Option 3"; var opt4 = Option.Factory(OptionTypes.Html); opt3.Name = "Option 4"; var opt5 = Option.Factory(OptionTypes.Html); opt3.Name = "Option 5"; var opt6 = Option.Factory(OptionTypes.Html); opt3.Name = "Option 6"; var opt7 = Option.Factory(OptionTypes.Html); opt3.Name = "Option 7"; // Add the option p.Options.Add(opt); p.Options.Add(opt2); p.Options.Add(opt3); p.Options.Add(opt4); p.Options.Add(opt5); p.Options.Add(opt6); p.Options.Add(opt7); Assert.IsTrue(app.CatalogServices.Products.Create(p)); var actual = app.CatalogServices.Products.Find(p.Bvin); Assert.IsNotNull(actual, "Actual product should not be null"); Assert.AreEqual(7, actual.Options.Count, "There should be one option on the product"); Assert.AreEqual(opt.Name, actual.Options[0].Name, "Option name didn't match"); Assert.AreEqual(opt2.Name, actual.Options[1].Name, "Option2 name didn't match"); Assert.AreEqual(opt3.Name, actual.Options[2].Name, "Option3 name didn't match"); Assert.AreEqual(opt4.Name, actual.Options[3].Name, "Option4 name didn't match"); Assert.AreEqual(opt5.Name, actual.Options[4].Name, "Option5 name didn't match"); Assert.AreEqual(opt6.Name, actual.Options[5].Name, "Option6 name didn't match"); Assert.AreEqual(opt7.Name, actual.Options[6].Name, "Option7 name didn't match"); }