Skip to content

Commit

Permalink
Merge pull request #5 from ajp8164/feature/add-test-get-invoices
Browse files Browse the repository at this point in the history
Feature/add test get invoices
  • Loading branch information
ionux committed Dec 11, 2014
2 parents 8e39bde + ac1157f commit 6bc89ed
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
6 changes: 0 additions & 6 deletions BitPay.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitPay", "BitPay\BitPay.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitPayTest", "BitPayTest\BitPayTest.csproj", "{71166BF5-DA31-4BFD-90E6-16172E894EAA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitPayExtensions", "Utils\BitPayExtensions.csproj", "{97707074-7E0E-4185-A37F-BD9215BAEFA9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,10 +19,6 @@ Global
{71166BF5-DA31-4BFD-90E6-16172E894EAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71166BF5-DA31-4BFD-90E6-16172E894EAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71166BF5-DA31-4BFD-90E6-16172E894EAA}.Release|Any CPU.Build.0 = Release|Any CPU
{97707074-7E0E-4185-A37F-BD9215BAEFA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97707074-7E0E-4185-A37F-BD9215BAEFA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97707074-7E0E-4185-A37F-BD9215BAEFA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97707074-7E0E-4185-A37F-BD9215BAEFA9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
14 changes: 7 additions & 7 deletions BitPay/BitPay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ public Invoice getInvoice(String invoiceId)
/// <summary>
/// Retrieve a list of invoices by date range using the merchant facade.
/// </summary>
/// <param name="dateStart">The start date for the query in UNIX epoch time.</param>
/// <param name="dateEnd">The end date for the query in UNIX epoch time.</param>
/// <param name="dateStart">The start date for the query.</param>
/// <param name="dateEnd">The end date for the query.</param>
/// <returns>A list of invoice objects retrieved from the server.</returns>
public List<Invoice> getInvoices(String dateStart, String dateEnd)
public List<Invoice> getInvoices(DateTime dateStart, DateTime dateEnd)
{
Dictionary<String, String> parameters = this.getParams();
parameters.Add("token", this.getAccessToken(FACADE_MERCHANT));
parameters.Add("dateStart", dateStart);
parameters.Add("dateEnd", dateEnd);
parameters.Add("dateStart", dateStart.ToShortDateString());
parameters.Add("dateEnd", dateEnd.ToShortDateString());
HttpResponseMessage response = this.get("invoices", parameters);
return JsonConvert.DeserializeObject<List<Invoice>>(this.responseToJsonString(response));
}
Expand All @@ -221,8 +221,8 @@ public Rates getRates()
/// Retrieve a list of ledgers by date range using the merchant facade.
/// </summary>
/// <param name="currency">The three digit currency string for the ledger to retrieve.</param>
/// <param name="dateStart">The start date for the query in UNIX epoch time.</param>
/// <param name="dateEnd">The end date for the query in UNIX epoch time.</param>
/// <param name="dateStart">The start date for the query.</param>
/// <param name="dateEnd">The end date for the query.</param>
/// <returns>A list of invoice objects retrieved from the server.</returns>
public Ledger getLedger(String currency, DateTime dateStart, DateTime dateEnd)
{
Expand Down
6 changes: 0 additions & 6 deletions BitPay/BitPay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Utils\BitPayExtensions.csproj">
<Project>{97707074-7e0e-4185-a37f-bd9215baefa9}</Project>
<Name>BitPayExtensions</Name>
</ProjectReference>
</ItemGroup>
<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.
Expand Down
16 changes: 15 additions & 1 deletion BitPayTest/BitPayTest2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,27 @@ public void testShouldGetInvoiceId()
}
}

[TestMethod]
public void testShouldGetInvoices()
{
try
{
List<Invoice> invoices = bitpay.getInvoices(new DateTime(2014, 8, 1), new DateTime(2014, 8, 31));
Assert.IsTrue(invoices.Count > 0, "No invoices retrieved");
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
}

[TestMethod]
public void testShouldGetBTCLedger()
{
try
{
Ledger ledger = this.bitpay.getLedger(Ledger.LEDGER_BTC, new DateTime(2014, 8, 1), new DateTime(2014, 8, 31));
Assert.IsTrue(ledger.Entries.Count > 0, "No invoices returned");
Assert.IsTrue(ledger.Entries.Count > 0, "Ledger is empty");
}
catch (Exception ex)
{
Expand Down

0 comments on commit 6bc89ed

Please sign in to comment.