public void Init() { _destination = new Address() { Name = "Mindfly Web Design Studio", Address1 = "114 W. Magnolia St. Suite 504", Locality = "Bellingham", Region = "WA", PostalCode = "98225", CountryCode = "US" }; PreTestDataWorker.DeleteAllItemCaches(); PreTestDataWorker.DeleteAllInvoices(); _customer = PreTestDataWorker.MakeExistingAnonymousCustomer(); _basket = Basket.GetBasket(MerchelloContext, _customer); for (var i = 0; i < ProductCount; i++) { _basket.AddItem(PreTestDataWorker.MakeExistingProduct(true, WeightPerProduct, PricePerProduct)); } Basket.Save(MerchelloContext, _basket); _shipCountry = ShipCountryService.GetShipCountryByCountryCode(Catalog.Key, "US"); }
public void DeleteAllShipCountries() { var shipCountries = ((ShipCountryService)ShipCountryService).GetAllShipCountries(); foreach (var country in shipCountries.Where(x => !x.CountryCode.Equals(Constants.CountryCodes.EverywhereElse))) { ShipCountryService.Delete(country); } }
public void Can_Get_Quotes_For_All_Active_ShipMethods() { #region BackOffice //// Arrange var dkCountry = ShipCountryService.GetShipCountryByCountryCode(Catalog.Key, "DK"); var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey; var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Current.Gateways.Shipping.CreateInstance(key); rateTableProvider.DeleteAllActiveShipMethods(_shipCountry); var gwshipMethod1 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, _shipCountry, "Ground (Vary By Pricc) 1"); gwshipMethod1.RateTable.AddRow(0, 10, 5); gwshipMethod1.RateTable.AddRow(10, 15, 10); gwshipMethod1.RateTable.AddRow(15, 25, 25); gwshipMethod1.RateTable.AddRow(25, 60, 30); // total price should be 50M so we should hit this tier gwshipMethod1.RateTable.AddRow(25, 10000, 50); rateTableProvider.SaveShippingGatewayMethod(gwshipMethod1); var gwshipMethod2 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByWeight, _shipCountry, "Ground (VBW)"); gwshipMethod2.RateTable.AddRow(0, 10, 5); gwshipMethod2.RateTable.AddRow(10, 15, 10); // total weight should be 10M so we should hit this tier gwshipMethod2.RateTable.AddRow(15, 25, 25); gwshipMethod2.RateTable.AddRow(25, 10000, 100); rateTableProvider.SaveShippingGatewayMethod(gwshipMethod2); var gwshipMethod3 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, dkCountry, "Ground (Vary By Price) 3"); gwshipMethod3.RateTable.AddRow(0, 10, 5); gwshipMethod3.RateTable.AddRow(10, 15, 10); gwshipMethod3.RateTable.AddRow(15, 25, 25); gwshipMethod3.RateTable.AddRow(25, 60, 30); // total price should be 50M so we should hit this tier gwshipMethod3.RateTable.AddRow(25, 10000, 50); rateTableProvider.SaveShippingGatewayMethod(gwshipMethod3); #endregion // var shipments = CurrentCustomer.Basket.PackageBasket(_destinationAddress); //// Act var shipments = _basket.PackageBasket(MerchelloContext.Current, _destination); Assert.IsTrue(shipments.Any()); var quotes = rateTableProvider.QuoteShippingGatewayMethodsForShipment(shipments.First()).OrderBy(x => x.Rate); Console.Write("Basket total price: {0}", _basket.TotalBasketPrice); //// Assert Assert.IsTrue(quotes.Any()); Assert.AreEqual(2, quotes.Count()); Assert.AreEqual(5M, quotes.First().Rate); Assert.AreEqual(30M, quotes.Last().Rate); }
public void Can_Add_A_Shipmethod_To_A_Provider_With_A_ShipCountry() { //// Arrange var country = ShipCountryService.GetShipCountryByCountryCode(Catalog.Key, "US"); var shippingProvider = MerchelloContext.Gateways.Shipping.GetAllActivatedProviders().FirstOrDefault() as ShippingGatewayProviderBase; Assert.NotNull(shippingProvider); //// Act var resource = shippingProvider.ListResourcesOffered().FirstOrDefault(); var gatewayShipMethod = shippingProvider.CreateShippingGatewayMethod(resource, country, "Ground"); shippingProvider.SaveShippingGatewayMethod(gatewayShipMethod); //// Assert Assert.IsTrue(gatewayShipMethod.ShipMethod.HasIdentity); }
public override void FixtureSetup() { base.FixtureSetup(); #region BackOffice //// Arrange var usCountry = ShipCountryService.GetShipCountryByCountryCode(Catalog.Key, "US"); var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey; var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Gateways.Shipping.CreateInstance(key); rateTableProvider.DeleteAllActiveShipMethods(usCountry); var gwshipMethod1 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, usCountry, "Ground (Vary By Pricc) 1"); gwshipMethod1.RateTable.AddRow(0, 10, 5); gwshipMethod1.RateTable.AddRow(10, 15, 10); gwshipMethod1.RateTable.AddRow(15, 25, 25); gwshipMethod1.RateTable.AddRow(25, 60, 30); // total price should be 50M so we should hit this tier gwshipMethod1.RateTable.AddRow(25, 10000, 50); rateTableProvider.SaveShippingGatewayMethod(gwshipMethod1); var gwshipMethod2 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByWeight, usCountry, "Ground (VBW)"); gwshipMethod2.RateTable.AddRow(0, 10, 5); gwshipMethod2.RateTable.AddRow(10, 15, 10); // total weight should be 10M so we should hit this tier gwshipMethod2.RateTable.AddRow(15, 25, 25); gwshipMethod2.RateTable.AddRow(25, 10000, 100); rateTableProvider.SaveShippingGatewayMethod(gwshipMethod2); var gwshipMethod3 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, usCountry, "Ground (Vary By Price) 3"); gwshipMethod3.RateTable.AddRow(0, 10, 5); gwshipMethod3.RateTable.AddRow(10, 15, 10); gwshipMethod3.RateTable.AddRow(15, 25, 25); gwshipMethod3.RateTable.AddRow(25, 60, 30); // total price should be 50M so we should hit this tier gwshipMethod3.RateTable.AddRow(25, 10000, 50); rateTableProvider.SaveShippingGatewayMethod(gwshipMethod3); #endregion _shippingProvider = rateTableProvider; }
public void Can_Return_A_Valid_List_Of_ActiveShipMethods() { //// Arrange var dkCountry = ShipCountryService.GetShipCountryByCountryCode(Catalog.Key, "DK"); var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey; var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Current.Gateways.Shipping.CreateInstance(key); rateTableProvider.DeleteAllActiveShipMethods(_shipCountry); var gwshipMethod1 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, _shipCountry, "Ground (PercentTotal) 1"); var gwshipMethod2 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, _shipCountry, "Ground (PercentTotal) 2"); var gwshipMethod3 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, dkCountry, "Ground (PercentTotal) 3"); //// Act var shipments = _basket.PackageBasket(MerchelloContext.Current, _destination); Assert.IsTrue(shipments.Any()); var retrievedMethods = rateTableProvider.GetShippingGatewayMethodsForShipment(shipments.First()); //// Assert Assert.IsTrue(retrievedMethods.Any()); Assert.AreEqual(2, retrievedMethods.Count()); }