示例#1
0
    public async Task Return_FedEx_Rates_For_FedEx_Ground_Package_Business_Address_Successfully()
    {
        var rateService = _sp.GetRequiredService <IFedExRateProvider>();
        var destination = new Address("750 County Road 456", "Jonesboro", "AR", "72404", "US", isResidential: false);

        var packages = new List <Package>
        {
            // fedex envelope
            FedExRateConfigurator.GetFedExEnvelop(0.03125M)
        };

        var shipOptions = new ShipmentOptions
        {
            PackagingType         = nameof(FedExPackageType.YOUR_PACKAGING),
            SaturdayDelivery      = true,
            ShippingDate          = DateTime.Now.AddBusinessDays(1),
            PreferredCurrencyCode = ShipmentOptions.DefaultCurrencyCode,
        };

        var shipment = new Shipment(_origin, destination, packages, shipOptions);
        var rates    = await rateService.GetRatesAsync(shipment, ServiceType.FEDEX_GROUND);

        foreach (var rate in rates.Rates)
        {
            _output.WriteLine("{0}-{1}-{2}-{3}-{4}", rate.Name, rate.GuaranteedDelivery, rate.TotalCharges, rate.TotalCharges2, rate.SaturdayDelivery);
        }

        Assert.Single(rates.Rates);
    }
示例#2
0
    public async Task Return_FedEx_Rates_For_Envelope_Or_Pak_Successfully(decimal weight, int count, string packageType)
    {
        var rateService = _sp.GetRequiredService <IFedExRateProvider>();
        var destination = new Address("152 Ski Cove Ln", "Hartsville", "SC", "29550", "US");
        var package     = FedExRateConfigurator.GetFedExEnvelop(weight);

        var config = new FedExRateConfigurator(_origin, destination, package, DateTime.Now);

        var s = config.Shipments.Any(x => x.shipment.Options.PackagingType == packageType);

        Assert.True(s);

        Assert.Equal(count, config.Shipments.Count);

        foreach (var(shipment, serviceType) in config.Shipments)
        {
            var rates = await rateService.GetRatesAsync(shipment, serviceType);

            foreach (var rate in rates.Rates)
            {
                Assert.InRange(rates.Rates.Count, 1, 8);
                _output.WriteLine("{0} - {1} - ${2} - ${3} - {4}", rate.Name, rate.GuaranteedDelivery, rate.TotalCharges, rate.TotalCharges2, rate.SaturdayDelivery);
            }
        }
    }
示例#3
0
    public async Task Return_FedEx_Rate_For_Intl_Envelope_Successfully()
    {
        var rateService = _sp.GetRequiredService <IFedExRateProvider>();

        var destination = new Address("47 PEDMORE VALLEY", "NOTTINGHAM", string.Empty, "NG5 5NZ", "GB", isResidential: true);

        var packages = new List <Package>
        {
            // fedex envelope
            FedExRateConfigurator.GetFedExEnvelop(0.05M),
        };

        var shipOptions = new ShipmentOptions
        {
            PackagingType         = nameof(FedExPackageType.FEDEX_ENVELOPE),
            SaturdayDelivery      = true,
            ShippingDate          = DateTime.Now,
            PreferredCurrencyCode = ShipmentOptions.DefaultCurrencyCode
        };

        var shipment = new Shipment(_origin, destination, packages, shipOptions);

        var rates = await rateService.GetRatesAsync(shipment);

        foreach (var rate in rates.Rates)
        {
            _output.WriteLine("{0}-{1}-{2}-{3}-{4}", rate.Name, rate.GuaranteedDelivery, rate.TotalCharges, rate.TotalCharges2, rate.SaturdayDelivery);
        }

        // FEDEX INTERNATIONAL FIRST - 5 / 6 / 2021 10:00:00 AM - 125.26 - 125.26 - False
        // FEDEX INTERNATIONAL PRIORITY - 5 / 6 / 2021 12:00:00 PM - 18.16 - 72.46 - False
        // FEDEX INTERNATIONAL ECONOMY - 5 / 11 / 2021 6:00:00 PM - 23.56 - 109.23 - False
        Assert.Equal(3, rates.Rates.Count);
    }
示例#4
0
    public async Task Return_FedEx_Canada()
    {
        var rateService = _sp.GetRequiredService <IFedExRateProvider>();
        var destination = new Address("550 WELLINGTON RD Dock G", "Honeywell Department", "LONDON", "ON", "N6C 0A7", "CA", isResidential: false);
        var package     = FedExRateConfigurator.GetFedExEnvelop(0.03M, 7.90m, true);
        var config      = new FedExRateConfigurator(_origin, destination, package, DateTime.Now);

        foreach (var(shipment, serviceType) in config.Shipments)
        {
            var result = await rateService.GetRatesAsync(shipment, serviceType);

            Assert.True(result.Rates.Count > 0);
        }
    }