Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulfire86 committed Jan 31, 2017
2 parents 415cf6b + 203f80f commit 9ab9a78
Show file tree
Hide file tree
Showing 29 changed files with 1,198 additions and 655 deletions.
6 changes: 0 additions & 6 deletions .nuget/packages.config

This file was deleted.

32 changes: 15 additions & 17 deletions DotNetShipping.Tests/DotNetShipping.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -11,10 +9,12 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DotNetShipping.Tests</RootNamespace>
<AssemblyName>DotNetShipping.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<NuGetPackageImportStamp>eb75e32f</NuGetPackageImportStamp>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -46,16 +46,21 @@
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Features\FedExSmartPostShipRates.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Features\FedExShipRates.cs" />
<Compile Include="Features\UPSRates.cs" />
Expand All @@ -65,7 +70,7 @@
<Compile Include="Units\RateManagerFactoryTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
Expand All @@ -79,13 +84,6 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
54 changes: 44 additions & 10 deletions DotNetShipping.Tests/Features/FedExShipRates.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
using System.Linq;
using System;
using System.Configuration;
using System.Linq;

using DotNetShipping.ShippingProviders;

using Xunit;

namespace DotNetShipping.Tests.Features
{
public class FedExShipRates
public abstract class FedExShipRatesTestsBase : IDisposable
{
[Fact]
public void FedExReturnsRates()
protected readonly RateManager _rateManager;

protected FedExShipRatesTestsBase()
{
var rateManager = RateManagerFactory.Build();
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"]);

var from = new Address("Salt Lake City", "UT", "84119", "US");
var to = new Address("Beverly Hills", "CA", "90210", "US");
var package = new Package(12, 12, 12, 12, 0);
_rateManager = new RateManager();
_rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexUseProduction));
}

var r = rateManager.GetRates(from, to, package);
public void Dispose()
{

}
}

var fedExRates = r.Rates.Where(x => x.Provider == "FedEx").ToList();
public class FedExShipRates : FedExShipRatesTestsBase
{
[Fact]
public void FedExReturnsRates()
{
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 r = _rateManager.GetRates(from, to, package);
var fedExRates = r.Rates.ToList();

Assert.NotNull(r);
Assert.True(fedExRates.Any());

Expand All @@ -27,5 +51,15 @@ public void FedExReturnsRates()
Assert.True(rate.TotalCharges > 0);
}
}

[Fact]
public void CanGetFedExServiceCodes()
{
var provider = new FedExProvider();
var serviceCodes = provider.GetServiceCodes();

Assert.NotNull(serviceCodes);
Assert.NotEmpty(serviceCodes);
}
}
}
70 changes: 70 additions & 0 deletions DotNetShipping.Tests/Features/FedExSmartPostShipRates.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using DotNetShipping.ShippingProviders;

using Xunit;

namespace DotNetShipping.Tests.Features
{
public abstract class FedExSmartPostShipRatesTestsBase : IDisposable
{
protected readonly RateManager _rateManager;

protected FedExSmartPostShipRatesTestsBase()
{
var appSettings = ConfigurationManager.AppSettings;
var fedexKey = appSettings["FedExKey"];
var fedexPassword = appSettings["FedExPassword"];
var fedexAccountNumber = appSettings["FedExAccountNumber"];
var fedexMeterNumber = appSettings["FedExMeterNumber"];
var fedexHubId = appSettings["FedExHubId"];
var fedexUseProduction = Convert.ToBoolean(appSettings["FedExUseProduction"]);

_rateManager = new RateManager();
_rateManager.AddProvider(new FedExSmartPostProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexHubId, fedexUseProduction));
}

public void Dispose()
{

}
}

public class FedExSmartPostShipRates : FedExSmartPostShipRatesTestsBase
{
[Fact]
public void FedExSmartPostReturnsRates()
{
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 r = _rateManager.GetRates(from, to, package);
var fedExRates = r.Rates.ToList();

Assert.NotNull(r);
Assert.True(fedExRates.Any());

foreach (var rate in fedExRates)
{
Assert.True(rate.TotalCharges > 0);
Assert.Equal(rate.ProviderCode, "SMART_POST");
}
}

[Fact]
public void CanGetFedExServiceCodes()
{
var provider = new FedExProvider();
var serviceCodes = provider.GetServiceCodes();

Assert.NotNull(serviceCodes);
Assert.NotEmpty(serviceCodes);
}
}
}
33 changes: 33 additions & 0 deletions DotNetShipping.Tests/Features/UPSRates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ public void UPS_Returns_Multiple_Rates_When_Using_Valid_Addresses_For_All_Servic
}
}

[Fact]
public void UPS_Returns_Rates_When_Using_International_Origin_And_Destination_Addresses_For_All_Services()
{
var rateManager = new RateManager();
rateManager.AddProvider(new UPSProvider(UPSLicenseNumber, UPSUserId, UPSPassword));

var response = rateManager.GetRates(InternationalAddress2, 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);
}
}

[Fact]
public void UPS_Returns_Rates_When_Using_International_Destination_Addresses_For_All_Services()
{
Expand Down Expand Up @@ -145,5 +168,15 @@ public void UPS_Returns_Single_Rate_When_Using_Domestic_Addresses_For_Single_Ser

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

[Fact]
public void CanGetUpsServiceCodes()
{
var provider = new UPSProvider();
var serviceCodes = provider.GetServiceCodes();

Assert.NotNull(serviceCodes);
Assert.NotEmpty(serviceCodes);
}
}
}
10 changes: 10 additions & 0 deletions DotNetShipping.Tests/Features/USPSDomesticRates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,15 @@ public void USPS_Domestic_Returns_Single_Rate_When_Using_Valid_Addresses_For_Sin

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

[Fact]
public void CanGetUspsServiceCodes()
{
var provider = new USPSProvider();
var serviceCodes = provider.GetServiceCodes();

Assert.NotNull(serviceCodes);
Assert.NotEmpty(serviceCodes);
}
}
}
12 changes: 11 additions & 1 deletion DotNetShipping.Tests/Features/USPSInternationalRates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public USPSInternationalRates()
_internationalAddress1 = new Address("Jubail", "Jubail", "31951", "SA"); //has limited intl services available
_internationalAddress2 = new Address("80-100 Victoria St", "", "", "London", "", "SW1E 5JL", "GB");

_package1 = new Package(4, 4, 4, 5, 0);
_package1 = new Package(14, 14, 14, 15, 0);
_package2 = new Package(6, 6, 6, 5, 100);

_uspsUserId = ConfigurationManager.AppSettings["USPSUserId"];
Expand Down Expand Up @@ -130,5 +130,15 @@ public void USPS_Intl_Returns_Single_Rate_When_Using_Valid_Addresses_For_Single_

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

[Fact]
public void CanGetUspsInternationalServiceCodes()
{
var provider = new USPSInternationalProvider();
var serviceCodes = provider.GetServiceCodes();

Assert.NotNull(serviceCodes);
Assert.NotEmpty(serviceCodes);
}
}
}
11 changes: 8 additions & 3 deletions SampleApp/App.config → DotNetShipping.Tests/app.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Expand All @@ -13,15 +13,20 @@
<add key="FedExPassword" value="" />
<add key="FedExAccountNumber" value="" />
<add key="FedExMeterNumber" value="" />
<add key="FedExHubId" value="5531" />
<add key="FedExUseProduction" value="false" />
<add key="USPSUserId" value="" />
</appSettings>
<applicationSettings>
<DotNetShipping.Properties.Settings>
<setting name="DotNetShipping_RateServiceWebReference_RateService" serializeAs="String">
<value>
https://ws.fedex.com:443/web-services/rate
https://wsbeta.fedex.com:443/web-services/rate
</value>
</setting>
</DotNetShipping.Properties.Settings>
</applicationSettings>
</configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
12 changes: 6 additions & 6 deletions DotNetShipping.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.0.0" targetFramework="net45" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
<package id="xunit.assert" version="2.0.0" targetFramework="net45" />
<package id="xunit.core" version="2.0.0" targetFramework="net45" />
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net45" />
<package id="xunit" version="2.1.0" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net452" />
<package id="xunit.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net452" />
</packages>
Loading

0 comments on commit 9ab9a78

Please sign in to comment.