public void CanRetrieveShippingMethod() { RequestContext c = new RequestContext(); MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c); c.CurrentStore = new Accounts.Store(); c.CurrentStore.Id = 230; Shipping.ShippingMethod target = new Shipping.ShippingMethod(); target.Adjustment = 1.23m; target.AdjustmentType = Shipping.ShippingMethodAdjustmentType.Percentage; target.Bvin = string.Empty; //target.CustomProperties.Add("bvsoftware", "mykey", "myvalue"); 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"); Shipping.ShippingMethod 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.CustomProperties[0].Key, target.CustomProperties[0].Key); 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 CanCreateShippingMethod() { RequestContext c = new RequestContext(); MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c); c.CurrentStore = new Accounts.Store(); c.CurrentStore.Id = 230; Shipping.ShippingMethod target = new Shipping.ShippingMethod(); target.Adjustment = 1.23m; target.AdjustmentType = Shipping.ShippingMethodAdjustmentType.Percentage; target.Bvin = string.Empty; //target.CustomProperties.Add("bvsoftware", "mykey", "myvalue"); target.Name = "Test Name"; target.Settings.AddOrUpdate("MySetting", "MySetVal"); target.ShippingProviderId = "123456"; target.ZoneId = -101; Assert.IsTrue(app.OrderServices.ShippingMethods.Create(target)); Assert.AreNotEqual(string.Empty, target.Bvin, "Bvin should not be empty"); }
public void CanUseShippingOverrideCorrectly() { RequestContext c = new RequestContext(); MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c); c.CurrentStore = new Accounts.Store(); c.CurrentStore.Id = 1; // Create Shipping Method Shipping.ShippingMethod m = new Shipping.ShippingMethod(); m.ShippingProviderId = "3D6623E7-1E2C-444d-B860-A8F542133093"; // Flat Rate Per Item m.Settings = new MerchantTribe.Shipping.Services.FlatRatePerItemSettings() { Amount = 1.50m }; m.Adjustment = 0m; m.Bvin = System.Guid.NewGuid().ToString(); m.Name = "Sample Order"; m.ZoneId = -100; // US All Zone app.OrderServices.ShippingMethods.Create(m); Order target = new Order(); target.BillingAddress.City = "Richmond"; target.BillingAddress.CountryBvin = MerchantTribe.Web.Geography.Country.UnitedStatesCountryBvin; target.BillingAddress.CountryName = "United States"; target.BillingAddress.Line1 = "124 Anywhere St."; target.BillingAddress.PostalCode = "23233"; target.BillingAddress.RegionBvin = "VA"; target.BillingAddress.RegionName = "VA"; target.ShippingAddress.City = "Richmond"; target.ShippingAddress.CountryBvin = MerchantTribe.Web.Geography.Country.UnitedStatesCountryBvin; target.ShippingAddress.CountryName = "United States"; target.ShippingAddress.Line1 = "124 Anywhere St."; target.ShippingAddress.PostalCode = "23233"; target.ShippingAddress.RegionBvin = "VA"; target.ShippingAddress.RegionName = "VA"; target.ShippingMethodId = m.Bvin; target.ShippingProviderId = m.ShippingProviderId; LineItem li = new LineItem() { BasePricePerItem = 19.99m, ProductName = "Sample Product", ProductSku = "ABC123", Quantity = 1, ShippingSchedule = -1 }; target.Items.Add(li); LineItem li2 = new LineItem() { BasePricePerItem = 19.99m, ProductName = "Sample Product 2", ProductSku = "ABC1232", Quantity = 1, ShippingSchedule = 1 }; target.Items.Add(li2); target.TotalShippingBeforeDiscountsOverride = 5.00m; app.CalculateOrder(target); Assert.AreEqual(39.98m, target.TotalOrderBeforeDiscounts, "SubTotal was Incorrect"); Assert.AreEqual(5.00m, target.TotalShippingBeforeDiscounts, "Shipping Total was not overridden"); Assert.AreEqual(44.98m, target.TotalGrand, "Grand Total was incorrect"); }