public void FedExTestRate() { #region Arrange var store = _application.CurrentStore; var testSettings = _irepo.GetTestRate_FedExSettings(); var servicecode = _irepo.GetTestRate_FedExServiceCode(); var testSvc = new FedExProvider(testSettings, new Web.Logging.TextLogger()) { Settings = { ServiceCode = servicecode, Packaging = (int)testSettings.DefaultPackaging } }; var testShipment = _irepo.GetTestRate_FedExShipment(store); var testItem = _irepo.GetTestRate_FedExShippableInfo(); testShipment.Items.Add(testItem); #endregion //Act var rates = testSvc.RateShipment(testShipment); //Assert if (rates == null) { Assert.AreEqual(1, 0); } else { Assert.AreEqual(25, rates.FirstOrDefault().EstimatedCost); } }
protected void btnTest_Click(object sender, EventArgs e) { SaveData(); var testSettings = new FedExGlobalServiceSettings { AccountNumber = AccountNumberField.Text, DefaultDropOffType = (DropOffType)int.Parse(lstDropOffType.SelectedValue), DefaultPackaging = (PackageType)int.Parse(lstPackaging.SelectedValue), DiagnosticsMode = true, ForceResidentialRates = chkResidential.Checked, MeterNumber = MeterNumberField.Text.Trim(), UserKey = KeyField.Text.Trim(), UserPassword = PasswordField.Text.Trim(), UseDevelopmentServiceUrl = chkDevelopmentUrl.Checked }; var logger = new TextLogger(); var testSvc = new FedExProvider(testSettings, logger) { Settings = { ServiceCode = int.Parse(lstServicesTest.SelectedValue), Packaging = (int)testSettings.DefaultPackaging } }; var testShipment = new Shipment { DestinationAddress = DestinationAddress.GetAsAddress(), SourceAddress = SourceAddress.GetAsAddress() }; var testItem = new Shippable { BoxHeight = decimal.Parse(TestHeight.Text), BoxLength = decimal.Parse(TestLength.Text), BoxWidth = decimal.Parse(TestWidth.Text), BoxLengthType = LengthType.Inches, BoxWeight = decimal.Parse(TestWeight.Text), BoxWeightType = WeightType.Pounds }; testShipment.Items.Add(testItem); var sb = new StringBuilder(); sb.AppendFormat(Localization.GetString("StartingTest"), DateTime.Now); sb.Append("<br />"); var rates = testSvc.RateShipment(testShipment); foreach (var r in rates) { sb.AppendFormat(Localization.GetString("RateFound"), r.EstimatedCost.ToString("C"), r.DisplayName, r.ServiceCodes, r.ServiceId); sb.Append("<br />"); } sb.Append("<br />"); sb.Append(Localization.GetString("Log")); sb.Append(":<br />"); foreach (var m in logger.Messages) { sb.Append(m + "<br />"); } sb.AppendFormat(Localization.GetString("FinishedTest"), DateTime.Now); litTestOuput.Text = sb.ToString(); }