forked from 7digital/SevenDigital.Api.Wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to specify route parameters in endpoint info
- Loading branch information
Antony Denyer
committed
Dec 16, 2011
1 parent
2a356f9
commit 6c8a8e9
Showing
5 changed files
with
135 additions
and
3 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
109 changes: 109 additions & 0 deletions
109
src/SevenDigital.Api.Wrapper.Unit.Tests/EndpointResolution/EndpointResolverTests.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,109 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Xml.Serialization; | ||
using FakeItEasy; | ||
using NUnit.Framework; | ||
using SevenDigital.Api.Schema.Attributes; | ||
using SevenDigital.Api.Wrapper.EndpointResolution; | ||
using SevenDigital.Api.Wrapper.EndpointResolution.OAuth; | ||
using SevenDigital.Api.Wrapper.Utility.Http; | ||
|
||
namespace SevenDigital.Api.Wrapper.Unit.Tests.EndpointResolution | ||
{ | ||
[TestFixture] | ||
public class EndpointResolverTests | ||
{ | ||
private EndpointResolver _endpointResolver; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
var urlResolver = A.Fake<IUrlResolver>(); | ||
A.CallTo(() => urlResolver.Resolve(A<Uri>.Ignored, A<string>.Ignored, A<Dictionary<string, string>>.Ignored)) | ||
.Returns(string.Empty); | ||
|
||
var apiUri = A.Fake<IApiUri>(); | ||
A.CallTo(() => apiUri.Uri) | ||
.Returns("http://uri/"); | ||
|
||
_endpointResolver = new EndpointResolver(urlResolver, new UrlSigner(), new AppSettingsCredentials(), apiUri); | ||
} | ||
|
||
[Test] | ||
public void should_substitue_route_parameters() | ||
{ | ||
var endpointInfo = new EndPointInfo | ||
{ | ||
Uri = "something/{route}", | ||
Parameters = new Dictionary<string, string> | ||
{ | ||
{"route","routevalue"} | ||
} | ||
}; | ||
|
||
var result = _endpointResolver.ConstructEndpoint(endpointInfo); | ||
|
||
Assert.That(result,Is.StringContaining("something/routevalue")); | ||
} | ||
|
||
[Test] | ||
public void should_substitue_multiple_route_parameters() | ||
{ | ||
var endpointInfo = new EndPointInfo | ||
{ | ||
Uri = "something/{firstRoute}/{secondRoute}/thrid/{thirdRoute}", | ||
Parameters = new Dictionary<string, string> | ||
{ | ||
{"firstRoute" , "firstValue"}, | ||
{"secondRoute","secondValue"}, | ||
{"thirdRoute" , "thirdValue"} | ||
|
||
} | ||
}; | ||
|
||
var result = _endpointResolver.ConstructEndpoint(endpointInfo); | ||
|
||
Assert.That(result, Is.StringContaining("something/firstvalue/secondvalue/thrid/thirdvalue")); | ||
} | ||
|
||
[Test] | ||
public void routes_should_be_case_insensitive() | ||
{ | ||
var endpointInfo = new EndPointInfo | ||
{ | ||
Uri = "something/{firstRoUte}/{secOndrouTe}/thrid/{tHirdRoute}", | ||
Parameters = new Dictionary<string, string> | ||
{ | ||
{"firstRoute" , "firstValue"}, | ||
{"secondRoute","secondValue"}, | ||
{"thirdRoute" , "thirdValue"} | ||
|
||
} | ||
}; | ||
|
||
var result = _endpointResolver.ConstructEndpoint(endpointInfo); | ||
|
||
Assert.That(result, Is.StringContaining("something/firstvalue/secondvalue/thrid/thirdvalue")); | ||
} | ||
|
||
[Test] | ||
public void should_handle_dashes_and_numbers() | ||
{ | ||
var endpointInfo = new EndPointInfo | ||
{ | ||
Uri = "something/{route-66}", | ||
Parameters = new Dictionary<string, string> | ||
{ | ||
{"route-66","routevalue"} | ||
} | ||
}; | ||
|
||
var result = _endpointResolver.ConstructEndpoint(endpointInfo); | ||
|
||
Assert.That(result, Is.StringContaining("something/routevalue")); | ||
} | ||
|
||
} | ||
} |
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