summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/CoordinatorBase.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-03-07 17:00:03 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2013-03-07 17:00:03 -0800
commitbc505e8b3846ee97bec3860acce7d0d92b814955 (patch)
tree24c39d720943dac08754d095e5720565500eed3c /src/DotNetOpenAuth.Test/CoordinatorBase.cs
parent5c50924246387b6d9a5ce668fb389b5ec7d93434 (diff)
downloadDotNetOpenAuth-bc505e8b3846ee97bec3860acce7d0d92b814955.zip
DotNetOpenAuth-bc505e8b3846ee97bec3860acce7d0d92b814955.tar.gz
DotNetOpenAuth-bc505e8b3846ee97bec3860acce7d0d92b814955.tar.bz2
Many more unit test build fixes and product touch-ups.
Diffstat (limited to 'src/DotNetOpenAuth.Test/CoordinatorBase.cs')
-rw-r--r--src/DotNetOpenAuth.Test/CoordinatorBase.cs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth.Test/CoordinatorBase.cs b/src/DotNetOpenAuth.Test/CoordinatorBase.cs
index 6a3ad86..83b9e6e 100644
--- a/src/DotNetOpenAuth.Test/CoordinatorBase.cs
+++ b/src/DotNetOpenAuth.Test/CoordinatorBase.cs
@@ -9,6 +9,7 @@ namespace DotNetOpenAuth.Test {
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
+ using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using DotNetOpenAuth.Messaging;
@@ -55,6 +56,20 @@ namespace DotNetOpenAuth.Test {
internal Handler By(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> handler) {
return new Handler(this.Uri) { MessageHandler = handler };
}
+
+ internal Handler By(Func<HttpRequestMessage, HttpResponseMessage> handler) {
+ return By((req, ct) => Task.FromResult(handler(req)));
+ }
+
+ internal Handler By(string responseContent, string contentType, HttpStatusCode statusCode = HttpStatusCode.OK) {
+ return By(
+ req => {
+ var response = new HttpResponseMessage(statusCode);
+ response.Content = new StringContent(responseContent);
+ response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
+ return response;
+ });
+ }
}
private class MyHostFactories : IHostFactories {
@@ -82,7 +97,7 @@ namespace DotNetOpenAuth.Test {
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {
foreach (var handler in this.handlers) {
- if (handler.Uri.AbsolutePath == request.RequestUri.AbsolutePath) {
+ if (handler.Uri.IsBaseOf(request.RequestUri) && handler.Uri.AbsolutePath == request.RequestUri.AbsolutePath) {
var response = await handler.MessageHandler(request, cancellationToken);
if (response != null) {
return response;