Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added/updates Api test to include InMemory Api's
- Loading branch information
Matheu
committed
Jan 17, 2012
1 parent
66b8598
commit 0460b86
Showing
12 changed files
with
323 additions
and
11 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,11 @@ | ||
<Configuration> | ||
<SnapshotDialog> | ||
<InitialDirectory>D:\JustGiving\JustGiving.Api.Sdk\DotNet\src</InitialDirectory> | ||
</SnapshotDialog> | ||
<CoverageFilters> | ||
<IncludeFilters> | ||
<Filter ModuleMask="*" ClassMask="*" FunctionMask="*" /> | ||
</IncludeFilters> | ||
<ExcludeFilters /> | ||
</CoverageFilters> | ||
</Configuration> |
36 changes: 36 additions & 0 deletions
36
DotNet/src/JustGiving.Api.Sdk.Test.Integration/ApiClients/InMemoryApiTests.cs
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,36 @@ | ||
using JustGiving.Api.Sdk.ApiClients; | ||
using NUnit.Framework; | ||
|
||
namespace JustGiving.Api.Sdk.Test.Integration.ApiClients | ||
{ | ||
[TestFixture] | ||
public class InMemoryApiTests | ||
{ | ||
[TestCase(WireDataFormat.Json)] | ||
[TestCase(WireDataFormat.Xml)] | ||
public void GetRememberPerson_WhenProvidedWithValidPersonId_ReturnsRememberPersonDetails(WireDataFormat format) | ||
{ | ||
var client = TestContext.CreateClientValidCredentials(format); | ||
var inMemoryClient = new InMemoryApi(client.HttpChannel); | ||
int rememberPersonId = 21; | ||
|
||
var response = inMemoryClient.Retrieve(rememberPersonId); | ||
|
||
Assert.AreEqual(response.RememberedPerson.Id, rememberPersonId); | ||
Assert.That(response.CollectionUri, Is.StringContaining(string.Format("remember/{0}/", response.RememberedPerson.Id))); | ||
} | ||
|
||
[TestCase(WireDataFormat.Json)] | ||
[TestCase(WireDataFormat.Xml)] | ||
public void GetRememberPersonCollectionData_WhenProvidedWithValidPersonId_ReturnsRememberPersonCollectionData(WireDataFormat format) | ||
{ | ||
var client = TestContext.CreateClientValidCredentials(format); | ||
var inMemoryClient = new InMemoryApi(client.HttpChannel); | ||
int rememberPersonId = 21; | ||
|
||
var retrieveCollectionData = inMemoryClient.RetrieveCollectionData(rememberPersonId); | ||
|
||
Assert.Greater(retrieveCollectionData.Pages.Length, 0); | ||
} | ||
} | ||
} |
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
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
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,10 @@ | ||
using JustGiving.Api.Sdk.Model.Remember; | ||
|
||
namespace JustGiving.Api.Sdk.ApiClients | ||
{ | ||
public interface IInMemoryApi: IInMemoryApiAsync | ||
{ | ||
RememberedPersonResponse Retrieve(int rememberedPersonId); | ||
RememberedPersonCollection RetrieveCollectionData(int rememberedPersonId); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
DotNet/src/JustGiving.Api.Sdk/ApiClients/IInMemoryApiAsync.cs
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,11 @@ | ||
using System; | ||
using JustGiving.Api.Sdk.Model.Remember; | ||
|
||
namespace JustGiving.Api.Sdk.ApiClients | ||
{ | ||
public interface IInMemoryApiAsync | ||
{ | ||
void RetrieveAsync(int rememberedPersonId, Action<RememberedPersonResponse> callback); | ||
void RetrieveCollectionDataAsync(int rememberedPersonId, Action<RememberedPersonResponse> callback); | ||
} | ||
} |
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,49 @@ | ||
using System; | ||
using JustGiving.Api.Sdk.Http; | ||
using JustGiving.Api.Sdk.Model.Remember; | ||
|
||
namespace JustGiving.Api.Sdk.ApiClients | ||
{ | ||
public class InMemoryApi: ApiClientBase, IInMemoryApi | ||
{ | ||
public override string ResourceBase | ||
{ | ||
get { return "{apiKey}/v{apiVersion}/remember"; } | ||
} | ||
|
||
public InMemoryApi(HttpChannel channel) | ||
: base(channel) | ||
{ | ||
} | ||
|
||
public string RetrieveLocationFormat(int rememberedPersonId) | ||
{ | ||
return ResourceBase + "/" + rememberedPersonId; | ||
} | ||
|
||
public RememberedPersonResponse Retrieve(int rememberedPersonId) | ||
{ | ||
var locationFormat = RetrieveLocationFormat(rememberedPersonId) ; | ||
return HttpChannel.PerformRequest<RememberedPersonResponse>("GET", locationFormat); | ||
} | ||
|
||
public void RetrieveAsync(int rememberedPersonId, Action<RememberedPersonResponse> callback) | ||
{ | ||
var locationFormat = RetrieveLocationFormat(rememberedPersonId); | ||
HttpChannel.PerformRequestAsync("GET", locationFormat, callback); | ||
} | ||
|
||
public RememberedPersonCollection RetrieveCollectionData(int rememberedPersonId) | ||
{ | ||
var locationFormat = RetrieveLocationFormat(rememberedPersonId)+ "/collection"; | ||
return HttpChannel.PerformRequest<RememberedPersonCollection>("GET", locationFormat); | ||
} | ||
|
||
public void RetrieveCollectionDataAsync(int rememberedPersonId, Action<RememberedPersonResponse> callback) | ||
{ | ||
var locationFormat = RetrieveLocationFormat(rememberedPersonId) + "/collection"; | ||
HttpChannel.PerformRequestAsync("GET", locationFormat, callback); | ||
} | ||
|
||
} | ||
} |
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
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
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
83 changes: 83 additions & 0 deletions
83
DotNet/src/JustGiving.Api.Sdk/Model/Remember/RememberedPersonReference.cs
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,83 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
using JustGiving.Api.Sdk.Model.Summaries; | ||
|
||
namespace JustGiving.Api.Sdk.Model.Remember | ||
{ | ||
[DataContract(Name = "rememberedPersonReference", Namespace = "")] | ||
public class RememberedPersonReference | ||
{ | ||
[DataMember(Name = "relationship")] | ||
public string Relationship { get; set; } | ||
|
||
[DataMember(Name = "rememberedPerson")] | ||
public RememberedPerson RememberedPerson { get; set; } | ||
|
||
} | ||
|
||
[DataContract(Name = "rememberedPersonResponse", Namespace = "")] | ||
public class RememberedPersonResponse | ||
{ | ||
[DataMember(Name = "rememberedPerson")] | ||
public RememberedPerson RememberedPerson { get; set; } | ||
|
||
[DataMember(Name = "collectionUri")] | ||
public string CollectionUri { get; set; } | ||
} | ||
|
||
[DataContract(Name = "rememberedPerson", Namespace = "")] | ||
public class RememberedPerson | ||
{ | ||
[DataMember(Name = "id")] | ||
public int Id { get; set; } | ||
|
||
[DataMember(Name = "firstName")] | ||
public string FirstName { get; set; } | ||
|
||
[DataMember(Name = "lastName")] | ||
public string LastName { get; set; } | ||
|
||
[DataMember(Name = "gender")] | ||
public int? Gender { get; set; } | ||
|
||
[DataMember(Name = "town")] | ||
public string Town { get; set; } | ||
|
||
[DataMember(Name = "dateOfBirth")] | ||
public DateTime? DateOfBirth { get; set; } | ||
|
||
[DataMember(Name = "dateOfDeath")] | ||
public DateTime? DateOfDeath { get; set; } | ||
} | ||
|
||
[DataContract(Name = "rememberedPersonCollection", Namespace = "")] | ||
public class RememberedPersonCollection | ||
{ | ||
[DataMember(Name = "grandTotal")] | ||
public decimal GrandTotal { get; set; } | ||
|
||
[DataMember(Name = "pages")] | ||
public PageSummary[] Pages { get; set; } | ||
|
||
[DataMember(Name = "charities")] | ||
public CharitySummary[] Charities { get; set; } | ||
|
||
[DataMember(Name = "events")] | ||
public EventSummary[] Events { get; set; } | ||
|
||
} | ||
|
||
[DataContract(Name = "rememberedPersonSummary", Namespace = "")] | ||
public class RememberedPersonSummary | ||
{ | ||
[DataMember(Name = "name")] | ||
public string Name { get; set; } | ||
|
||
[DataMember(Name = "id")] | ||
public string Id { get; set; } | ||
|
||
[DataMember(Name = "next")] | ||
public RestResponseNextElement Next { get; set; } | ||
|
||
} | ||
} |
Oops, something went wrong.