public void Can_Create_And_Persist_A_GatewayShipMethod_With_A_RateTable() { //// Arrange var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey; var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Current.Gateways.Shipping.CreateInstance(key); rateTableProvider.DeleteAllActiveShipMethods(_shipCountry); var expected = 4; //// Act var gwshipMethod = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByWeight, _shipCountry, "Ground (VBW)"); gwshipMethod.RateTable.AddRow(0, 10, 5); gwshipMethod.RateTable.AddRow(10, 15, 10); gwshipMethod.RateTable.AddRow(15, 25, 25); gwshipMethod.RateTable.AddRow(25, 10000, 100); // have to call this via the static method due o the MerchelloContext.Current not present in the ShipRateTable object. ShippingFixedRateTable.Save(GatewayProviderService, MerchelloContext.Current.Cache.RuntimeCache, gwshipMethod.RateTable); var retrieved = (FixedRateShippingGatewayMethod)rateTableProvider.GetAllShippingGatewayMethods(_shipCountry).First(); ////// Assert Assert.NotNull(retrieved); Assert.AreEqual("Ground (VBW)", retrieved.ShipMethod.Name); Assert.AreEqual(expected, retrieved.RateTable.Rows.Count()); }
public void Can_Insert_A_Row_At_The_Middle_Of_An_Existing_RateTable_Row() { //// Arrange var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey; var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Current.Gateways.Shipping.CreateInstance(key); rateTableProvider.DeleteAllActiveShipMethods(_shipCountry); var gwshipMethod = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByWeight, _shipCountry, "Ground (VBW)"); gwshipMethod.RateTable.AddRow(0, 10, 5); gwshipMethod.RateTable.AddRow(10, 15, 10); gwshipMethod.RateTable.AddRow(15, 25, 25); gwshipMethod.RateTable.AddRow(25, 35, 100); ShippingFixedRateTable.Save(GatewayProviderService, MerchelloContext.Current.Cache.RuntimeCache, gwshipMethod.RateTable); //// Act gwshipMethod.RateTable.AddRow(18, 22, 100); ShippingFixedRateTable.Save(GatewayProviderService, MerchelloContext.Current.Cache.RuntimeCache, gwshipMethod.RateTable); var retrieved = (FixedRateShippingGatewayMethod)rateTableProvider.GetAllShippingGatewayMethods(_shipCountry).First(); ////// Assert Assert.NotNull(retrieved); Assert.NotNull(retrieved.RateTable.Rows.FirstOrDefault(x => x.RangeLow == 18)); Assert.AreEqual(5, retrieved.RateTable.Rows.Count()); }