public async Task Get_First_Class_Package_2oz_Successfully() { var sp = GetServices(); var provider = sp.GetRequiredService <IUspsRateProvider>(); Assert.NotNull(provider); // https://www.stamps.com/usps/first-class-package-service/ // USPS First-Class Package Service - Retail- $4.15 weight .0125M var destination = new Address(" 6828 ARJAY DR", "INDIANAPOLIS", "IN", "46217 - 3001", "US", isResidential: true); // USPS First-Class Package Service - Retail-6.40- PACKAGE_SERVICE_RETAIL // USPS First-Class Mail Large Envelope - 3.40 - FLAT var weight = 2.00m / 16; var package = UspsRateConfigurator.GetFirstClassPackage(weight); var config = new UspsRateConfigurator(_origin, destination, package, DateTime.Now); var(shipment, rateOptions) = config.Shipments[0]; var result = await provider.GetRatesAsync(shipment, rateOptions); var rate = result.Rates.FirstOrDefault(); Assert.NotNull(rate); Assert.Equal(4.15m, rate?.TotalCharges); _output.WriteLine($"{rate?.ServiceName} - ${rate?.TotalCharges} - {rate?.GuaranteedDelivery}"); }
public async Task Get_First_Class_And_Priority_Mail_Successfully(decimal weightInOz, decimal charge) { var sp = GetServices(); var provider = sp.GetRequiredService <IUspsRateProvider>(); Assert.NotNull(provider); // https://www.stamps.com/usps/first-class-package-service/ // USPS First-Class Package Service - Retail- $4.15 weight .0125M var destination = new Address("229 S GREEN ST", "HENDERSON", "KY", "42420-3540", "US", isResidential: true); var weight = weightInOz / 16; var package = UspsRateConfigurator.GetFirstClassPackage(weight); var configs = new UspsRateConfigurator(_origin, destination, package, DateTime.Now); foreach (var(shipment, rateOptions) in configs.Shipments) { var result = await provider.GetRatesAsync(shipment, rateOptions); var rate = result.Rates.FirstOrDefault(); Assert.NotNull(rate); // Assert.Equal(charge, rate.TotalCharges); _output.WriteLine($"{rate?.ServiceName} - ${rate?.TotalCharges} - {rate?.GuaranteedDelivery}"); } }