Beispiel #1
0
        private static void Main()
        {
            var appSettings = ConfigurationManager.AppSettings;

            // You will need a license #, userid and password to utilize the UPS provider.
            var upsLicenseNumber = appSettings["UPSLicenseNumber"];
            var upsUserId        = appSettings["UPSUserId"];
            var upsPassword      = appSettings["UPSPassword"];

            // You will need an account # and meter # to utilize the FedEx provider.
            var fedexKey           = appSettings["FedExKey"];
            var fedexPassword      = appSettings["FedExPassword"];
            var fedexAccountNumber = appSettings["FedExAccountNumber"];
            var fedexMeterNumber   = appSettings["FedExMeterNumber"];
            var fedexHubId         = appSettings["FedExHubId"]; // 5531 is the hubId to use in FedEx's test environment
            var fedexUseProduction = Convert.ToBoolean(appSettings["FedExUseProduction"]);

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            var uspsUserId = appSettings["USPSUserId"];

            // Setup package and destination/origin addresses
            var packages = new List <Package>();

            packages.Add(new Package(12, 12, 12, 35, 150));
            packages.Add(new Package(4, 4, 6, 15, 250));

            var origin      = new Address("", "", "06405", "US");
            var destination = new Address("", "", "20852", "US"); // US Address
            //var destination = new Address("", "", "00907", "PR"); // Puerto Rico Address
            //var destination = new Address("", "", "L4W 1S2", "CA"); // Canada Address
            //var destination = new Address("", "", "SW1E 5JL", "GB"); // UK Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword)
            {
                UseProduction = false
            });
            rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexUseProduction));
            rateManager.AddProvider(new FedExSmartPostProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexHubId, fedexUseProduction));
            rateManager.AddProvider(new USPSProvider(uspsUserId));
            rateManager.AddProvider(new USPSInternationalProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            rateManager.AddRateAdjuster(new PercentageRateAdjuster(.9M));

            // Call GetRates()
            var shipment = rateManager.GetRates(origin, destination, packages);

            // Iterate through the rates returned
            foreach (var rate in shipment.Rates)
            {
                Console.WriteLine(rate);
            }

            Console.ReadLine();
        }
        private static void Main()
        {
            var appSettings = ConfigurationManager.AppSettings;

            // You will need a license #, userid and password to utilize the UPS provider.
            var upsLicenseNumber = appSettings["UPSLicenseNumber"];
            var upsUserId = appSettings["UPSUserId"];
            var upsPassword = appSettings["UPSPassword"];

            // You will need an account # and meter # to utilize the FedEx provider.
            var fedexKey = appSettings["FedExKey"];
            var fedexPassword = appSettings["FedExPassword"];
            var fedexAccountNumber = appSettings["FedExAccountNumber"];
            var fedexMeterNumber = appSettings["FedExMeterNumber"];
            var fedexHubId = appSettings["FedExHubId"];

            // 5531 is the hubId to use in FedEx's test environment

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            var uspsUserId = appSettings["USPSUserId"];

            // Setup package and destination/origin addresses
            var packages = new List<Package>();
            packages.Add(new Package(12, 12, 12, 35, 150));
            packages.Add(new Package(4, 4, 6, 15, 250));

            var origin = new Address("", "", "06405", "US");
            var destination = new Address("", "", "20852", "US"); // US Address
            //var destination = new Address("", "", "00907", "PR"); // Puerto Rico Address
            //var destination = new Address("", "", "L4W 1S2", "CA"); // Canada Address
            //var destination = new Address("", "", "SW1E 5JL", "GB"); // UK Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword) {UseProduction = false});
            rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, false));
            rateManager.AddProvider(new FedExSmartPostProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexHubId, false));
            rateManager.AddProvider(new USPSProvider(uspsUserId));
            rateManager.AddProvider(new USPSInternationalProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            rateManager.AddRateAdjuster(new PercentageRateAdjuster(.9M));

            // Call GetRates()
            var shipment = rateManager.GetRates(origin, destination, packages);

            // Iterate through the rates returned
            foreach (var rate in shipment.Rates)
            {
                Console.WriteLine(rate);
            }

            Console.ReadLine();
        }
Beispiel #3
0
        private static void Main()
        {
            NameValueCollection appSettings = ConfigurationManager.AppSettings;

            // You will need a license #, userid and password to utilize the UPS provider.
            string upsLicenseNumber = appSettings["UPSLicenseNumber"];
            string upsUserId        = appSettings["UPSUserId"];
            string upsPassword      = appSettings["UPSPassword"];

            // You will need an account # and meter # to utilize the FedEx provider.
            string fedexKey           = appSettings["FedExKey"];
            string fedexPassword      = appSettings["FedExPassword"];
            string fedexAccountNumber = appSettings["FedExAccountNumber"];
            string fedexMeterNumber   = appSettings["FedExMeterNumber"];

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            string uspsUserId = appSettings["USPSUserId"];

            // Setup package and destination/origin addresses
            var packages = new List <Package>();

            packages.Add(new Package(12, 12, 12, 35, 150));
            packages.Add(new Package(4, 4, 6, 15, 250));

            var origin      = new Address("", "", "06405", "US");
            var destination = new Address("", "", "20852", "US"); // US Address
            //var destination = new Address("", "", "00907", "PR"); // Puerto Rico Address
            //var destination = new Address("", "", "L4W 1S2", "CA"); // Canada Address
            //var destination = new Address("80-100 Victoria St", "", "", "London SW1E 5JL", "", "", "United Kingdom"); // UK Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword)
            {
                UseProduction = false
            });
            rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber));
            rateManager.AddProvider(new USPSProvider(uspsUserId));
            //rateManager.AddProvider(new USPSInternationalProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            rateManager.AddRateAdjuster(new PercentageRateAdjuster(.9M));

            // Call GetRates()
            Shipment shipment = rateManager.GetRates(origin, destination, packages);

            // Iterate through the rates returned
            foreach (Rate rate in shipment.Rates)
            {
                Console.WriteLine(rate);
            }
        }
Beispiel #4
0
        private static void Main()
        {
            NameValueCollection appSettings = ConfigurationManager.AppSettings;

            // You will need a license #, userid and password to utilize the UPS provider.
            string upsLicenseNumber = appSettings["UPSLicenseNumber"];
            string upsUserId = appSettings["UPSUserId"];
            string upsPassword = appSettings["UPSPassword"];

            // You will need an account # and meter # to utilize the FedEx provider.
            string fedexKey = appSettings["FedExKey"];
            string fedexPassword = appSettings["FedExPassword"];
            string fedexAccountNumber = appSettings["FedExAccountNumber"];
            string fedexMeterNumber = appSettings["FedExMeterNumber"];

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            string uspsUserId = appSettings["USPSUserId"];

            // Setup package and destination/origin addresses
            var packages = new List<Package>();
            packages.Add(new Package(12, 12, 12, 35, 150));
            packages.Add(new Package(4, 4, 6, 15, 250));

            var origin = new Address("", "", "06405", "US");
            var destination = new Address("", "", "20852", "US"); // US Address
            //var destination = new Address("", "", "L4W 1S2", "CA"); // Canada Address
            //var destination = new Address("80-100 Victoria St", "", "", "London SW1E 5JL", "", "", "United Kingdom"); // UK Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword));
            rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber));
            rateManager.AddProvider(new USPSProvider(uspsUserId));
            //rateManager.AddProvider(new USPSInternationalProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            rateManager.AddRateAdjuster(new PercentageRateAdjuster(.9M));

            // Call GetRates()
            Shipment shipment = rateManager.GetRates(origin, destination, packages);

            // Iterate through the rates returned
            foreach (Rate rate in shipment.Rates)
            {
                Console.WriteLine(rate);
            }
        }
Beispiel #5
0
        public async Task UPSSaturdayDelivery()
        {
            var from    = new Address("Annapolis", "MD", "21401", "US");
            var to      = new Address("Fitchburg", "WI", "53711", "US");
            var package = new Package(7, 7, 7, 6, 0);

            var today      = DateTime.Now;
            var nextFriday = today.AddDays(12 - (int)today.DayOfWeek);

            var rateManager = new RateManager();

            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword));

            var r = await rateManager.GetRatesAsync(from, to, package, new ShipmentOptions()
            {
                ShippingDate     = nextFriday,
                SaturdayDelivery = true
            });

            var fedExRates = r.Rates.ToList();

            Assert.NotNull(r);
            Assert.True(fedExRates.Any());
            Assert.True(fedExRates.Any(r => r.Options.SaturdayDelivery));
        }
        public void Can_Get_Different_Rates_For_Signature_Required_Lookup()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSProvider(USPSUserId, "Priority Mail"));

            var nonSignatureResponse = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);
            var signatureResponse    = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1SignatureRequired);

            // Assert that we have a non-signature response
            Assert.NotNull(nonSignatureResponse);
            Assert.NotEmpty(nonSignatureResponse.Rates);
            Assert.Empty(nonSignatureResponse.ServerErrors);
            Assert.True(nonSignatureResponse.Rates.First().TotalCharges > 0);

            // Assert that we have a signature response
            Assert.NotNull(signatureResponse);
            Assert.NotEmpty(signatureResponse.Rates);
            Assert.Empty(signatureResponse.ServerErrors);
            Assert.True(signatureResponse.Rates.First().TotalCharges > 0);

            // Now compare prices
            foreach (var signatureRate in signatureResponse.Rates)
            {
                var nonSignatureRate = nonSignatureResponse.Rates.FirstOrDefault(x => x.Name == signatureRate.Name);

                if (nonSignatureRate != null)
                {
                    var signatureTotalCharges    = signatureRate.TotalCharges;
                    var nonSignatureTotalCharges = nonSignatureRate.TotalCharges;
                    Assert.NotEqual(signatureTotalCharges, nonSignatureTotalCharges);
                }
            }
        }
Beispiel #7
0
        public void UPS_Returns_Rates_When_Using_International_Destination_Addresses_And_RetailRates_For_All_Services()
        {
            var rateManager = new RateManager();
            var provider    = new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword)
            {
                UseRetailRates = true
            };

            rateManager.AddProvider(provider);

            var response = rateManager.GetRates(DomesticAddress1, InternationalAddress1, Package1);

            Debug.WriteLine($"Rates returned: {(response.Rates.Any() ? response.Rates.Count.ToString() : "0")}");

            Assert.NotNull(response);
            Assert.IsNotEmpty(response.Rates);
            Assert.IsEmpty(response.Errors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
Beispiel #8
0
        public void USPS_Intl_Returns_Multiple_Rates_When_Using_Multiple_Packages_For_All_Services_And_Multiple_Packages()
        {
            var packages = new List <Package>();

            packages.Add(_package1);
            packages.Add(_package2);

            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSInternationalProvider(_uspsUserId));

            var response = rateManager.GetRates(_domesticAddress1, _internationalAddress2, packages);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
        public void USPS_Intl_Returns_Multiple_Rates_When_Using_Multiple_Packages_For_All_Services_And_Multiple_Packages()
        {
            var packages = new List<Package>();
            packages.Add(_package1);
            packages.Add(_package2);

            var rateManager = new RateManager();
            rateManager.AddProvider(new USPSInternationalProvider(_uspsUserId));

            var response = rateManager.GetRates(_domesticAddress1, _internationalAddress2, packages);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
Beispiel #10
0
        protected RateManager GetRateManager(DHLProviderConfiguration configuration)
        {
            var provider = new DHLProvider(configuration);

            var rateManager = new RateManager();

            rateManager.AddProvider(provider);

            return(rateManager);
        }
Beispiel #11
0
        protected FedExShipRatesTestsBase()
        {
            var appSettings        = ConfigurationManager.AppSettings;
            var fedexKey           = appSettings["FedExKey"];
            var fedexPassword      = appSettings["FedExPassword"];
            var fedexAccountNumber = appSettings["FedExAccountNumber"];
            var fedexMeterNumber   = appSettings["FedExMeterNumber"];
            var fedexUseProduction = Convert.ToBoolean(appSettings["FedExUseProduction"]);

            _rateManager = new RateManager();
            _rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexUseProduction));
        }
        protected FedExShipRatesTestsBase()
        {
            var appSettings = ConfigurationManager.AppSettings;
            var fedexKey = appSettings["FedExKey"];
            var fedexPassword = appSettings["FedExPassword"];
            var fedexAccountNumber = appSettings["FedExAccountNumber"];
            var fedexMeterNumber = appSettings["FedExMeterNumber"];
            var fedexUseProduction = Convert.ToBoolean(appSettings["FedExUseProduction"]);

            _rateManager = new RateManager();
            _rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexUseProduction));
        }
        public void USPS_Domestic_Returns_No_Rates_When_Using_Invalid_Addresses_For_All_Services()
        {
            var rateManager = new RateManager();
            rateManager.AddProvider(new USPSProvider(USPSUserId));

            var response = rateManager.GetRates(DomesticAddress1, InternationalAddress1, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.Empty(response.Rates);
            Assert.Empty(response.ServerErrors);
        }
Beispiel #14
0
        public void USPS_Intl_Returns_No_Rates_When_Using_Invalid_Addresses_For_All_Services()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSInternationalProvider(_uspsUserId));

            var response = rateManager.GetRates(_domesticAddress1, _domesticAddress2, _package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.Empty(response.Rates);
        }
Beispiel #15
0
        public async Task USPSCurrency()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSInternationalProvider(_uspsUserId));

            var response = await rateManager.GetRatesAsync(_domesticAddress1, _internationalAddress2, _package1);

            var rates = response.Rates;

            Assert.NotNull(response);
            Assert.True(rates.Any());
            Assert.False(rates.Any(r => r.CurrencyCode != "USD"));
        }
Beispiel #16
0
        public void USPS_Domestic_Returns_No_Rates_When_Using_Invalid_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSProvider(USPSUserId, "Priority Mail"));

            var response = rateManager.GetRates(DomesticAddress1, InternationalAddress1, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.Empty(response.Rates);
            Assert.Empty(response.ServerErrors);
        }
Beispiel #17
0
        protected FedExSmartPostShipRatesTestsBase()
        {
            var config = ConfigHelper.GetApplicationConfiguration(TestContext.CurrentContext.TestDirectory);

            var fedexKey           = config.FedExKey;
            var fedexPassword      = config.FedExPassword;
            var fedexAccountNumber = config.FedExAccountNumber;
            var fedexMeterNumber   = config.FedExMeterNumber;
            var fedexHubId         = config.FedExHubId;
            var fedexUseProduction = config.FedExUseProduction;

            _provider    = new FedExSmartPostProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexHubId, fedexUseProduction);
            _rateManager = new RateManager();
            _rateManager.AddProvider(_provider);
        }
        public void USPS_Intl_Returns_No_Rates_When_Using_Invalid_Addresses_For_Single_Service()
        {
            //can't rate intl with a domestic address

            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSInternationalProvider(USPSUserId, "Priority Mail International"));

            Shipment response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.Empty(response.Rates);
        }
Beispiel #19
0
        public async Task USPS_Domestic_Saturday_Delivery()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSProvider(_uspsUserId));

            var today        = DateTime.Now;
            var nextFriday   = today.AddDays(12 - (int)today.DayOfWeek).Date + new TimeSpan(10, 0, 0);
            var nextThursday = nextFriday.AddDays(-1);

            var origin      = new Address("", "", "06405", "US");
            var destination = new Address("", "", "20852", "US");

            var response = await rateManager.GetRatesAsync(origin, destination, Package1, new ShipmentOptions()
            {
                ShippingDate     = nextFriday,
                SaturdayDelivery = true
            });

            Assert.NotNull(response);
            Assert.IsNotEmpty(response.Rates);

            // Sometimes only Priority Mail Express 2-Day works and we have to try it on Thursday
            if (!response.Rates.Any(r => r.Options.SaturdayDelivery))
            {
                response = await rateManager.GetRatesAsync(origin, destination, Package1, new ShipmentOptions()
                {
                    ShippingDate     = nextThursday,
                    SaturdayDelivery = true
                });

                Assert.NotNull(response);
                Assert.IsNotEmpty(response.Rates);
            }

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.IsEmpty(response.Errors);
            Assert.True(response.Rates.Any(r => r.Options.SaturdayDelivery));

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
        public ActionResult Test()
        {
            System.Collections.Specialized.NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings;

            // You will need a license #, userid and password to utilize the UPS provider.
            string upsLicenseNumber = appSettings["UPSLicenseNumber"];
            string upsUserId        = appSettings["UPSUserId"];
            string upsPassword      = appSettings["UPSPassword"];

            // You will need an account # and meter # to utilize the FedEx provider.
            string fedexKey           = appSettings["FedExKey"];
            string fedexPassword      = appSettings["FedExPassword"];
            string fedexAccountNumber = appSettings["FedExAccountNumber"];
            string fedexMeterNumber   = appSettings["FedExMeterNumber"];

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            string uspsUserId = appSettings["USPSUserId"];

            // Setup package and destination/origin addresses
            var packages = new List <Package>();

            packages.Add(new Package(12, 12, 12, 35, 150));
            packages.Add(new Package(4, 4, 6, 15, 250));

            var origin      = new Address("", "", "06405", "US");
            var destination = new Address("", "", "20852", "US"); // US Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            rateManager.AddProvider(new DotNetShipping.ShippingProviders.UPSProvider(upsLicenseNumber, upsUserId, upsPassword));
            //rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber));
            //rateManager.AddProvider(new USPSProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            rateManager.AddRateAdjuster(new PercentageRateAdjuster(.9M));

            // Call GetRates()
            Shipment shipment = rateManager.GetRates(origin, destination, packages);

            // Iterate through the rates returned
            foreach (Rate rate in shipment.Rates)
            {
                Console.WriteLine(rate);
            }
            return(View());
        }
Beispiel #21
0
        public async Task UPSCurrency()
        {
            var from    = new Address("Amsterdam", "", "1043 AG", "NL");
            var to      = new Address("London", "", "SW1A 2AA", "GB");
            var package = new Package(1, 1, 1, 5, 1);

            var rateManager = new RateManager();

            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword));
            var r = await rateManager.GetRatesAsync(from, to, package);

            var fedExRates = r.Rates.ToList();

            Assert.NotNull(r);
            Assert.True(fedExRates.Any());
            Assert.False(fedExRates.Any(r => r.CurrencyCode != "EUR"));
        }
Beispiel #22
0
        public void USPS_Intl_Returns_Single_Rate_When_Using_Valid_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSInternationalProvider(_uspsUserId, "Priority Mail International"));

            var response = rateManager.GetRates(_domesticAddress1, _internationalAddress2, _package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.IsNotEmpty(response.Rates);
            Assert.IsEmpty(response.Errors);
            Assert.AreEqual(response.Rates.Count, 1);
            Assert.True(response.Rates.First().TotalCharges > 0);

            Debug.WriteLine(response.Rates.First().Name + ": " + response.Rates.First().TotalCharges);
        }
Beispiel #23
0
        public void UPS_Returns_Single_Rate_When_Using_Domestic_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword, "UPS Ground"));

            var response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine($"Rates returned: {(response.Rates.Any() ? response.Rates.Count.ToString() : "0")}");

            Assert.NotNull(response);
            Assert.IsNotEmpty(response.Rates);
            Assert.IsEmpty(response.Errors);
            Assert.AreEqual(response.Rates.Count, 1);
            Assert.True(response.Rates.First().TotalCharges > 0);

            Debug.WriteLine(response.Rates.First().Name + ": " + response.Rates.First().TotalCharges);
        }
Beispiel #24
0
        public void USPS_Domestic_Returns_Single_Rate_When_Using_Valid_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSProvider(USPSUserId, "Priority Mail"));

            var response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);
            Assert.Equal(response.Rates.Count, 1);
            Assert.True(response.Rates.First().TotalCharges > 0);

            Debug.WriteLine(response.Rates.First().Name + ": " + response.Rates.First().TotalCharges);
        }
        public void UPS_Domestic_Returns_Rates_When_Using_International_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();
            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword, "UPS Worldwide Express"));

            var response = rateManager.GetRates(DomesticAddress1, InternationalAddress1, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
Beispiel #26
0
        public void UPS_Returns_Multiple_Rates_When_Using_Valid_Addresses_For_All_Services()
        {
            var rateManager = new RateManager();
            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword));

            Shipment response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
Beispiel #27
0
        public void UPS_Returns_Multiple_Rates_When_Using_Valid_Addresses_For_All_Services_And_Multple_Packages()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword));

            var response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine($"Rates returned: {(response.Rates.Any() ? response.Rates.Count.ToString() : "0")}");

            Assert.NotNull(response);
            Assert.IsNotEmpty(response.Rates);
            Assert.IsEmpty(response.Errors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
        private Shipment CreateSpedizione(System.Collections.Specialized.NameValueCollection datiAccesso)
        {
            // You will need a license #, userid and password to utilize the UPS provider.
            string upsLicenseNumber = datiAccesso["UPSLicenseNumber"];
            string upsUserId        = datiAccesso["UPSUserId"];
            string upsPassword      = datiAccesso["UPSPassword"];

            // You will need an account # and meter # to utilize the FedEx provider.
            string fedexKey           = datiAccesso["FedExKey"];
            string fedexPassword      = datiAccesso["FedExPassword"];
            string fedexAccountNumber = datiAccesso["FedExAccountNumber"];
            string fedexMeterNumber   = datiAccesso["FedExMeterNumber"];

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            string uspsUserId = datiAccesso["USPSUserId"];

            // Setup package and destination/origin addresses
            var packages = new List <Package>();

            packages.Add(new Package(12, 12, 12, 35, 150));
            //packages.Add(new Package(4, 4, 6, 15, 250));

            var origin      = new Address("", "", "20026", "IT");
            var destination = new Address("", "", "20024", "IT"); // US Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            rateManager.AddProvider(new DotNetShipping.ShippingProviders.UPSProvider(upsLicenseNumber, upsUserId, upsPassword));
            //rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber));
            //rateManager.AddProvider(new USPSProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            //rateManager.AddRateAdjuster(new PercentageRateAdjuster(.9M));

            // Call GetRates()
            return(rateManager.GetRates(origin, destination, packages));
        }
Beispiel #29
0
        public void UPS_Returns_Rates_When_Using_International_Destination_Addresses_For_All_Services()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword));

            Shipment response = rateManager.GetRates(DomesticAddress1, InternationalAddress1, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
Beispiel #30
0
        public void USPS_Domestic_Returns_Multiple_Rates_When_Using_Valid_Addresses_For_All_Services_And_Multiple_Packages()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new USPSProvider(USPSUserId));

            var response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
Beispiel #31
0
        public void UPS_Domestic_Returns_Rates_When_Using_International_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword, "UPS Worldwide Express"));

            var response = rateManager.GetRates(DomesticAddress1, InternationalAddress1, Package1);

            Debug.WriteLine($"Rates returned: {(response.Rates.Any() ? response.Rates.Count.ToString() : "0")}");

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);

            foreach (var rate in response.Rates)
            {
                Assert.NotNull(rate);
                Assert.True(rate.TotalCharges > 0);

                Debug.WriteLine(rate.Name + ": " + rate.TotalCharges);
            }
        }
Beispiel #32
0
        public void Can_Get_Different_Rates_For_Signature_Required_Lookup()
        {
            var rateManager = new RateManager();

            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword, "UPS Ground"));

            var nonSignatureResponse = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);
            var signatureResponse    = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1SignatureRequired);

            Debug.WriteLine(string.Format("Rates returned: {0}", nonSignatureResponse.Rates.Any() ? nonSignatureResponse.Rates.Count.ToString() : "0"));

            Assert.NotNull(nonSignatureResponse);
            Assert.IsNotEmpty(nonSignatureResponse.Rates);
            Assert.IsEmpty(nonSignatureResponse.Errors);
            Assert.AreEqual(nonSignatureResponse.Rates.Count, 1);
            Assert.True(nonSignatureResponse.Rates.First().TotalCharges > 0);

            Debug.WriteLine(string.Format("Rates returned: {0}", signatureResponse.Rates.Any() ? signatureResponse.Rates.Count.ToString() : "0"));

            Assert.NotNull(signatureResponse);
            Assert.IsNotEmpty(signatureResponse.Rates);
            Assert.IsEmpty(signatureResponse.Errors);
            Assert.AreEqual(signatureResponse.Rates.Count, 1);
            Assert.True(signatureResponse.Rates.First().TotalCharges > 0);

            // Now compare prices
            foreach (var signatureRate in signatureResponse.Rates)
            {
                var nonSignatureRate = nonSignatureResponse.Rates.FirstOrDefault(x => x.Name == signatureRate.Name);

                if (nonSignatureRate != null)
                {
                    var signatureTotalCharges    = signatureRate.TotalCharges;
                    var nonSignatureTotalCharges = nonSignatureRate.TotalCharges;
                    Assert.AreNotEqual(signatureTotalCharges, nonSignatureTotalCharges);
                }
            }
        }
Beispiel #33
0
        public void UPS_Sure_Post_Returns_Valid_Rate()
        {
            var rateManager = new RateManager();

            var upsProvider = new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword, "UPS Sure Post");

            upsProvider.ShipperNumber      = "31E749";
            upsProvider.UseNegotiatedRates = true;

            rateManager.AddProvider(upsProvider);

            Shipment response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);
            Assert.Equal(response.Rates.Count, 1);
            Assert.True(response.Rates.First().TotalCharges > 0);

            Debug.WriteLine(response.Rates.First().Name + ": " + response.Rates.First().TotalCharges);
        }
Beispiel #34
0
        public void RateMethod()
        {
            var appSettings        = ConfigurationManager.AppSettings;
            var fedexKey           = appSettings["FedExKey"];
            var fedexPassword      = appSettings["FedExPassword"];
            var fedexAccountNumber = appSettings["FedExAccountNumber"];
            var fedexMeterNumber   = appSettings["FedExMeterNumber"];

            var packages = new List <Package>();

            packages.Add(new Package(0, 0, 0, 5, 0));



            //// var destination = new Address("RECIPIENT ADDRESS LINE 1", "", "", "Collierville", "TN", "38017", "US");
            // var origin = new Address("Zhong Shan Road 200", "", "", "NanJing", "", "210046", "CN");

            // var destination = new Address("SHIPPER ADDRESS LINE 1", "", "", "Austin", "TX", "73301", "US");


            var origin = new Address("SHIPPER ADDRESS LINE 1", "", "", "Austin", "TX", "73301", "US");

            var destination = new Address("栖霞区马群街道", "", "", "南京市", "", "210046", "CN");

            var rateManager = new RateManager();

            rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber));


            var shipment = rateManager.GetRates(origin, destination, packages);

            foreach (var rate in shipment.Rates)
            {
                Console.WriteLine(rate);
            }
            Console.ReadLine();
        }
        public void USPS_Intl_Returns_No_Rates_When_Using_Invalid_Addresses_For_Single_Service()
        {
            //can't rate intl with a domestic address

            var rateManager = new RateManager();
            rateManager.AddProvider(new USPSInternationalProvider(_uspsUserId, "Priority Mail International"));

            var response = rateManager.GetRates(_domesticAddress1, _domesticAddress2, _package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.Empty(response.Rates);
        }
Beispiel #36
0
        /// <summary>
        /// 计算Fedex费用
        /// </summary>
        /// <param name="ship"></param>
        /// <returns></returns>

        public ShipmentEx CalcPriceAdv(FedExQueryAdv ship)
        {
            ShipmentEx result = null;

            try
            {
                string      countyCode = string.Empty;
                string      countyName = string.Empty;
                CountryInfo county     = null;

                var packages = new List <Package>();

                Package pkg = null;

                //获取始发地

                //ShippingAddressInfo orgAddress = context.ShippingAddressInfo.SingleOrDefault(x => x.Id == ship.OrigId);

                //CountryInfo ortCity = context.CountryInfo.SingleOrDefault(x => x.ID == orgAddress.RegionId);

                //county = GetCountry(ortCity.PID);

                //if (county != null)
                //{
                //    countyCode = county.Code;
                //    countyName = county.ContryNameEN;
                //}

                //var origin = new Address(orgAddress.Address, "", "", ortCity.ContryNameEN, "", ortCity.Code, countyCode);
                //origin.CountryName = countyName;


                CountryInfo ortCity = context.CountryInfo.SingleOrDefault(x => x.ID == ship.OrigId);

                county = GetCountry(ortCity.PID);

                if (county != null)
                {
                    countyCode = county.Code;
                    countyName = county.ContryNameEN;
                }

                var origin = new Address(ship.OrigAddress, "", "", ortCity.ContryNameEN, "", ship.OrigPostCode, countyCode);
                origin.CountryName = countyName;


                //获取目的地
                ShippingAddressInfo destAddress = context.ShippingAddressInfo.SingleOrDefault(x => x.Id == ship.DestId);
                CountryInfo         destCity    = context.CountryInfo.SingleOrDefault(x => x.ID == destAddress.RegionId);
                county = null;
                county = GetCountry(destCity.PID);

                if (county != null)
                {
                    countyCode = county.Code;
                    countyName = county.ContryNameEN;
                }

                var destination = new Address(destAddress.Address, "", "", destCity.ContryNameEN, "", destAddress.PostCode, countyCode);
                destination.CountryName = countyName;



                foreach (ShipPackage item in ship.PackagesList)
                {
                    //if (item.Num > 0)
                    //{
                    //    for (int i = 0; i < item.Num; i++)
                    //    {
                    //        pkg = GetPackage(item);
                    //        pkg.Currency = ship.CoinType;
                    //        pkg.PackageCount = 1;
                    //        pkg.PackageType = "自备包装";
                    //        packages.Add(pkg);
                    //    }
                    //}
                    pkg              = GetPackage(item);
                    pkg.Currency     = ship.CoinType;
                    pkg.PackageCount = item.Num;
                    pkg.PackageType  = "自备包装";
                    packages.Add(pkg);
                }

                var rateManager = new RateManager();

                rateManager.AddProvider(new FedExProvider(ship.FedexKey, ship.FedexPassword, ship.FedexAccountNumber, ship.FedexMeterNumber));


                result = rateManager.GetRates(origin, destination, packages);

                if (result.Rates != null && result.Rates.Count > 0)
                {
                    result.RateValue = result.Rates[0];
                }
            }
            catch (Exception ex)
            {
            }

            return(result);
        }
Beispiel #37
0
        /// <summary>
        /// 计算顺丰物流费用
        /// </summary>
        /// <param name="ship"></param>
        /// <returns></returns>
        public ShipmentEx CalcSFCostAdv(FedExQueryAdv ship)
        {
            ShipmentEx result = null;

            try
            {
                SFRateRequest rateRequest = new SFRateRequest();
                string        countyCode  = string.Empty;
                string        countyName  = string.Empty;
                CountryInfo   county      = null;

                var packages = new List <Package>();

                Package pkg = null;


                CountryInfo ortCity = context.CountryInfo.SingleOrDefault(x => x.ID == ship.OrigId);

                if (ortCity != null)
                {
                    county = GetCountry(ortCity.PID);

                    if (county != null)
                    {
                        countyCode = county.Code;
                        countyName = county.ContryNameEN;

                        if (countyCode.ToUpper() != "CN")
                        {
                            rateRequest.OriginCode       = county.SFCode;
                            rateRequest.ParentOriginCode = county.SFCode;
                        }
                        else
                        {
                            rateRequest.OriginCode       = ortCity.SFCode;
                            rateRequest.ParentOriginCode = ortCity.SFCode;
                        }
                    }
                }


                var origin = new Address(ship.OrigAddress, "", "", ortCity.ContryNameEN, "", ship.OrigPostCode, countyCode);
                origin.CountryName = countyName;


                //获取目的地

                ShippingAddressInfo destAddress = context.ShippingAddressInfo.SingleOrDefault(x => x.Id == ship.DestId);
                CountryInfo         destCity    = context.CountryInfo.SingleOrDefault(x => x.ID == destAddress.RegionId);

                if (destCity != null)
                {
                    county = null;
                    county = GetCountry(destCity.PID);

                    if (county != null)
                    {
                        countyCode = county.Code;
                        countyName = county.ContryNameEN;
                        if (countyCode.ToUpper() != "CN")
                        {
                            rateRequest.DestCode       = county.SFCode;
                            rateRequest.ParentDestCode = county.SFCode;
                        }
                        else
                        {
                            rateRequest.DestCode       = destCity.SFCode;
                            rateRequest.ParentDestCode = destCity.SFCode;
                        }
                    }
                }

                var destination = new Address(destAddress.Address, "", "", destCity.ContryNameEN, "", destAddress.PostCode, countyCode);
                destination.CountryName = countyName;

                rateRequest.Volume    = 0;
                rateRequest.QueryType = 5;
                rateRequest.Lang      = "sc";
                rateRequest.Region    = "cn";

                foreach (ShipPackage item in ship.PackagesList)
                {
                    pkg              = GetPackage(item, 6000);
                    pkg.Currency     = ship.CoinType;
                    pkg.PackageCount = item.Num;
                    pkg.PackageType  = "自备包装";
                    packages.Add(pkg);
                }

                rateRequest.Weight = Math.Round(packages.Sum(x => x.Weight), 2);
                // rateRequest.Time = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd hh:mm");//"2016-07-06T13%3A30%3A00%2B08%3A00"

                DateTime dtNow = DateTime.Now;
                rateRequest.Time = string.Format("{0}T{1}%3A{2}%3A{3}%2B08%3A00", dtNow.ToString("yyyy-MM-dd"), dtNow.ToString("hh"), dtNow.ToString("mm"), dtNow.ToString("ss"));

                var rateManager = new RateManager();

                rateManager.AddProvider(new SFProvider(rateRequest));


                result = rateManager.GetRates(origin, destination, packages);

                if (result.Rates != null && result.Rates.Count > 0)
                {
                    result.RateValue = result.Rates[0];
                }
            }
            catch (Exception ex)
            {
            }

            return(result);
        }
        public void USPS_Intl_Returns_Single_Rate_When_Using_Valid_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();
            rateManager.AddProvider(new USPSInternationalProvider(_uspsUserId, "Priority Mail International"));

            var response = rateManager.GetRates(_domesticAddress1, _internationalAddress1, _package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);
            Assert.Equal(response.Rates.Count, 1);
            Assert.True(response.Rates.First().TotalCharges > 0);

            Debug.WriteLine(response.Rates.First().Name + ": " + response.Rates.First().TotalCharges);
        }
Beispiel #39
0
        private static void Start()
        {
            var appSettings = ConfigurationManager.AppSettings;

            // You will need a license #, userid and password to utilize the UPS provider.
            var upsLicenseNumber = "############";
            var upsUserId        = "############";
            var upsPassword      = ("############*");

            // You will need an account # and meter # to utilize the FedEx provider.
            var fedexKey           = "############"; //Test Key: "ffMloFez7JlC6YaK";
            var fedexPassword      = "******"; //Test Password: "******";
            var fedexAccountNumber = "############";
            var fedexMeterNumber   = "############"; //Productin Meter#:"118918154";
            var fedexHubId         = "5531";         // 5531 is the hubId to use in FedEx's test environment
            var fedexUseProduction = true;           //Convert.ToBoolean(appSettings["FedExUseProduction"]);

            // You will need a userId to use the USPS provider. Your account will also need access to the production servers.
            var uspsUserId = "############";


            //Gets state zipcode for destination (required by UPS for negotiated rates)
            var myZips        = new ZipTastic.getZipInfo();
            var myZipCodeData = new iZip();

            try { myZipCodeData = myZips.getZipData(zipcode, "US"); }catch (Exception e) { try { myZipCodeData = myZips.getZipData(zipcode, "CA"); } catch (Exception l) { MessageBox.Show("Please enter a valid zipcode."); return; } }



            // Sets package destination/ origin addresses
            //       origin: hard coded to Humboldt
            var origin      = new Address("", "", "#####", "US", false);
            var destination = new Address("", myZipCodeData.state_short, zipcode, myZipCodeData.country, res); // US Address
            //var destination = new Address("", "", "00907", "PR"); // Puerto Rico Address
            //var destination = new Address("", "", "L4W 1S2", "CA"); // Canada Address
            //var destination = new Address("", "", "SW1E 5JL", "GB"); // UK Address

            // Create RateManager
            var rateManager = new RateManager();

            // Add desired DotNetShippingProviders
            rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword)
            {
                UseProduction = true
            });
            //rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword, "UPS Ground"));
            rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexUseProduction, res));
            rateManager.AddProvider(new FedExSmartPostProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexHubId, fedexUseProduction));
            rateManager.AddProvider(new USPSProvider(uspsUserId, "Priority Commercial"));
            //rateManager.AddProvider(new USPSInternationalProvider(uspsUserId));

            // (Optional) Add RateAdjusters
            rateManager.AddRateAdjuster(new PercentageRateAdjuster(1.05M));

            // Call GetRates()
            var shipment = rateManager.GetRates(origin, destination, packages);

            if (shipment.Rates.Count == 0)
            {
                MessageBox.Show("Something went wrong, Check inputs");
            }

            decimal[] rates = new decimal[shipment.Rates.Count];

            string result = "";


            shipment.Rates.Sort((x, y) => decimal.Compare(x.TotalCharges, y.TotalCharges));


            foreach (var rate in shipment.Rates)
            {
                result += rate.Name + Environment.NewLine + "         $" + rate.TotalCharges.ToString("#,##0.00") + Environment.NewLine;
            }
            if (result != "")
            {
                MessageBox.Show(result);
            }



            //string restart = Console.ReadLine();

            //if(restart.ToLower() == "y")
            //{
            //    Console.WriteLine();
            //    Main();
            //};
        }
Beispiel #40
0
        public void UPS_Returns_Single_Rate_When_Using_Domestic_Addresses_For_Single_Service()
        {
            var rateManager = new RateManager();
            rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword, "UPS Ground"));

            Shipment response = rateManager.GetRates(DomesticAddress1, DomesticAddress2, Package1);

            Debug.WriteLine(string.Format("Rates returned: {0}", response.Rates.Any() ? response.Rates.Count.ToString() : "0"));

            Assert.NotNull(response);
            Assert.NotEmpty(response.Rates);
            Assert.Empty(response.ServerErrors);
            Assert.Equal(response.Rates.Count, 1);
            Assert.True(response.Rates.First().TotalCharges > 0);

            Debug.WriteLine(response.Rates.First().Name + ": " + response.Rates.First().TotalCharges);
        }