Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 71487bb
Showing
58 changed files
with
4,396 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<VisualState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ShowCheckBoxes="false"> | ||
<TopNode>[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests.nunit</TopNode> | ||
<SelectedNode>[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests.nunit</SelectedNode> | ||
<ExcludeCategories>false</ExcludeCategories> | ||
<Nodes> | ||
<Node UniqueName="[0-1005]C:\Users\pair\braintree-dotnet\Braintree.Tests\bin\Release\Braintree.Tests.dll" Expanded="true" /> | ||
<Node UniqueName="[0-1006]Braintree" Expanded="true" /> | ||
<Node UniqueName="[0-1007]Braintree.Tests" Expanded="true" /> | ||
<Node UniqueName="[0-1001]Braintree.Tests.Class1Test" Expanded="true" /> | ||
<Node UniqueName="[0-1003]Braintree.Tests.CustomerTest" Expanded="true" /> | ||
</Nodes> | ||
</VisualState> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<NUnitProject> | ||
<Settings activeconfig="Release" /> | ||
<Config name="Debug" binpathtype="Auto"> | ||
<assembly path="Braintree.Tests\bin\Debug\Braintree.Tests.dll" /> | ||
</Config> | ||
<Config name="Release" binpathtype="Auto"> | ||
<assembly path="Braintree.Tests\bin\Release\Braintree.Tests.dll" /> | ||
</Config> | ||
</NUnitProject> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using Braintree; | ||
|
||
namespace Braintree.Tests | ||
{ | ||
[TestFixture] | ||
class AddressTest | ||
{ | ||
private BraintreeGateway gateway; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
gateway = new BraintreeGateway | ||
{ | ||
Environment = Environment.DEVELOPMENT, | ||
MerchantID = "integration_merchant_id", | ||
PublicKey = "integration_public_key", | ||
PrivateKey = "integration_private_key" | ||
}; | ||
} | ||
|
||
[Test] | ||
public void Create_CreatesAddressForGivenCustomerID() | ||
{ | ||
String id = Guid.NewGuid().ToString(); | ||
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target; | ||
|
||
var addressRequest = new AddressRequest | ||
{ | ||
CustomerID = customer.ID, | ||
FirstName = "Michael", | ||
LastName = "Angelo", | ||
Company = "Angelo Co.", | ||
StreetAddress = "1 E Main St", | ||
ExtendedAddress = "Apt 3", | ||
Locality = "Chicago", | ||
Region = "IL", | ||
PostalCode = "60622", | ||
CountryName = "United States of America" | ||
}; | ||
|
||
Address address = gateway.Address.Create(customer.ID, addressRequest).Target; | ||
|
||
Assert.AreEqual("Michael", address.FirstName); | ||
Assert.AreEqual("Angelo", address.LastName); | ||
Assert.AreEqual("Angelo Co.", address.Company); | ||
Assert.AreEqual("1 E Main St", address.StreetAddress); | ||
Assert.AreEqual("Apt 3", address.ExtendedAddress); | ||
Assert.AreEqual("Chicago", address.Locality); | ||
Assert.AreEqual("IL", address.Region); | ||
Assert.AreEqual("60622", address.PostalCode); | ||
Assert.AreEqual("United States of America", address.CountryName); | ||
} | ||
|
||
[Test] | ||
public void Find_FindsAddress() | ||
{ | ||
String id = Guid.NewGuid().ToString(); | ||
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target; | ||
|
||
var addressRequest = new AddressRequest | ||
{ | ||
CustomerID = customer.ID, | ||
FirstName = "Michael", | ||
LastName = "Angelo", | ||
Company = "Angelo Co.", | ||
StreetAddress = "1 E Main St", | ||
ExtendedAddress = "Apt 3", | ||
Locality = "Chicago", | ||
Region = "IL", | ||
PostalCode = "60622", | ||
CountryName = "United States of America" | ||
}; | ||
|
||
Address createdAddress = gateway.Address.Create(customer.ID, addressRequest).Target; | ||
Address address = gateway.Address.Find(customer.ID, createdAddress.ID).Target; | ||
|
||
Assert.AreEqual("Michael", address.FirstName); | ||
Assert.AreEqual("Angelo", address.LastName); | ||
Assert.AreEqual("Angelo Co.", address.Company); | ||
Assert.AreEqual("1 E Main St", address.StreetAddress); | ||
Assert.AreEqual("Apt 3", address.ExtendedAddress); | ||
Assert.AreEqual("Chicago", address.Locality); | ||
Assert.AreEqual("IL", address.Region); | ||
Assert.AreEqual("60622", address.PostalCode); | ||
Assert.AreEqual("United States of America", address.CountryName); | ||
} | ||
|
||
[Test] | ||
public void Update_UpdatesAddressForGivenCustomerIDAndAddressID() | ||
{ | ||
String id = Guid.NewGuid().ToString(); | ||
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target; | ||
|
||
var addressCreateRequest = new AddressRequest | ||
{ | ||
CustomerID = customer.ID, | ||
FirstName = "Dave", | ||
LastName = "Inchy", | ||
Company = "Leon Ardo Co.", | ||
StreetAddress = "1 E State St", | ||
ExtendedAddress = "Apt 4", | ||
Locality = "Boston", | ||
Region = "MA", | ||
PostalCode = "11111", | ||
CountryName = "Canada" | ||
}; | ||
|
||
Address originalAddress = gateway.Address.Create(customer.ID, addressCreateRequest).Target; | ||
|
||
var addressUpdateRequest = new AddressRequest | ||
{ | ||
CustomerID = customer.ID, | ||
FirstName = "Michael", | ||
LastName = "Angelo", | ||
Company = "Angelo Co.", | ||
StreetAddress = "1 E Main St", | ||
ExtendedAddress = "Apt 3", | ||
Locality = "Chicago", | ||
Region = "IL", | ||
PostalCode = "60622", | ||
CountryName = "United States of America" | ||
}; | ||
|
||
Address address = gateway.Address.Update(customer.ID, originalAddress.ID, addressUpdateRequest).Target; | ||
|
||
Assert.AreEqual("Michael", address.FirstName); | ||
Assert.AreEqual("Angelo", address.LastName); | ||
Assert.AreEqual("Angelo Co.", address.Company); | ||
Assert.AreEqual("1 E Main St", address.StreetAddress); | ||
Assert.AreEqual("Apt 3", address.ExtendedAddress); | ||
Assert.AreEqual("Chicago", address.Locality); | ||
Assert.AreEqual("IL", address.Region); | ||
Assert.AreEqual("60622", address.PostalCode); | ||
Assert.AreEqual("United States of America", address.CountryName); | ||
} | ||
|
||
[Test] | ||
public void Delete_DeletesTheAddress() | ||
{ | ||
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target; | ||
|
||
var addressRequest = new AddressRequest | ||
{ | ||
CustomerID = customer.ID, | ||
StreetAddress = "1 E Main St", | ||
ExtendedAddress = "Apt 3", | ||
}; | ||
|
||
Address createdAddress = gateway.Address.Create(customer.ID, addressRequest).Target; | ||
Assert.AreEqual(createdAddress.ID, gateway.Address.Find(customer.ID, createdAddress.ID).Target.ID); | ||
gateway.Address.Delete(customer.ID, createdAddress.ID); | ||
Assert.Throws<NotFoundError>(() => gateway.Address.Find(customer.ID, createdAddress.ID)); | ||
} | ||
|
||
[Test] | ||
public void Create_ReturnsAnErrorResult() | ||
{ | ||
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target; | ||
AddressRequest request = new AddressRequest() { CountryName = "United States of Hammer" }; | ||
|
||
Result<Address> createResult = gateway.Address.Create(customer.ID, request); | ||
Assert.IsFalse(createResult.IsSuccess()); | ||
Dictionary<String, String> parameters = createResult.Parameters; | ||
Assert.AreEqual("integration_merchant_id", parameters["merchant_id"]); | ||
Assert.AreEqual(customer.ID, parameters["customer_id"]); | ||
Assert.AreEqual("United States of Hammer", parameters["address[country_name]"]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>9.0.30729</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{60234E7B-1181-4EFF-96EE-624B4524D788}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Braintree.Tests</RootNamespace> | ||
<AssemblyName>Braintree.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkSubset> | ||
</TargetFrameworkSubset> | ||
<StartupObject> | ||
</StartupObject> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- 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"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
<ItemGroup> | ||
<Reference Include="nunit.framework, Version=2.5.2.9222, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AddressTest.cs" /> | ||
<Compile Include="ConfigurationTest.cs" /> | ||
<Compile Include="CreditCardTest.cs" /> | ||
<Compile Include="CreditCardVerificationTest.cs" /> | ||
<Compile Include="CryptoTest.cs" /> | ||
<Compile Include="CustomerTest.cs" /> | ||
<Compile Include="QueryStringTest.cs" /> | ||
<Compile Include="TestHelper.cs" /> | ||
<Compile Include="TransactionTest.cs" /> | ||
<Compile Include="ValidationErrorsTest.cs" /> | ||
<Compile Include="WebServiceGatewayTest.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Braintree\Braintree.csproj"> | ||
<Project>{D0A473FA-E30B-4AF8-BB78-C1D81C9CAAB5}</Project> | ||
<Name>Braintree</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<VisualState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ShowCheckBoxes="false"> | ||
<TopNode>[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests\Braintree.Tests.csproj</TopNode> | ||
<SelectedNode>[0-1008]Braintree.Tests.CustomerTest.Delete_DeletesTheCustomer</SelectedNode> | ||
<ExcludeCategories>false</ExcludeCategories> | ||
<Nodes> | ||
<Node UniqueName="[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests\Braintree.Tests.csproj" Expanded="true" /> | ||
<Node UniqueName="[0-1009]C:\Users\pair\braintree-dotnet\Braintree.Tests\bin\Debug\Braintree.Tests.dll" Expanded="true" /> | ||
<Node UniqueName="[0-1010]Braintree" Expanded="true" /> | ||
<Node UniqueName="[0-1011]Braintree.Tests" Expanded="true" /> | ||
<Node UniqueName="[0-1001]Braintree.Tests.CustomerTest" Expanded="true" /> | ||
</Nodes> | ||
</VisualState> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using Braintree; | ||
|
||
namespace Braintree.Tests | ||
{ | ||
[TestFixture] | ||
class ConfigurationTest | ||
{ | ||
[Test] | ||
public void BaseMerchantURL_ReturnsDevelopmentURL() | ||
{ | ||
Configuration.Environment = Environment.DEVELOPMENT; | ||
Configuration.MerchantID = "integration_merchant_id"; | ||
Configuration.PublicKey = "integration_public_key"; | ||
Configuration.PrivateKey = "integration_private_key"; | ||
|
||
Assert.AreEqual("http://192.168.65.1:3000/merchants/integration_merchant_id", Configuration.BaseMerchantURL()); | ||
} | ||
|
||
[Test] | ||
public void BaseMerchantURL_ReturnsSandboxURL() | ||
{ | ||
Configuration.Environment = Environment.SANDBOX; | ||
Configuration.MerchantID = "integration_merchant_id"; | ||
Configuration.PublicKey = "integration_public_key"; | ||
Configuration.PrivateKey = "integration_private_key"; | ||
|
||
Assert.AreEqual("https://sandbox.braintreegateway.com:443/merchants/integration_merchant_id", Configuration.BaseMerchantURL()); | ||
} | ||
|
||
[Test] | ||
public void BaseMerchantURL_ReturnsProductionURL() | ||
{ | ||
Configuration.Environment = Environment.PRODUCTION; | ||
Configuration.MerchantID = "integration_merchant_id"; | ||
Configuration.PublicKey = "integration_public_key"; | ||
Configuration.PrivateKey = "integration_private_key"; | ||
|
||
|
||
Assert.AreEqual("https://www.braintreegateway.com:443/merchants/integration_merchant_id", Configuration.BaseMerchantURL()); | ||
} | ||
|
||
[Test] | ||
public void GetAuthorizationHeader_ReturnsBase64EncodePublicAndPrivateKeys() | ||
{ | ||
Configuration.Environment = Environment.DEVELOPMENT; | ||
Configuration.MerchantID = "integration_merchant_id"; | ||
Configuration.PublicKey = "integration_public_key"; | ||
Configuration.PrivateKey = "integration_private_key"; | ||
Assert.AreEqual("Basic aW50ZWdyYXRpb25fcHVibGljX2tleTppbnRlZ3JhdGlvbl9wcml2YXRlX2tleQ==", Configuration.GetAuthorizationHeader()); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.