diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-22 06:22:36 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-22 06:22:36 -0700 |
commit | 4c432c1278f301c3c80097866accca679e929fed (patch) | |
tree | d21dc94faeca5b600460abac10bd5080935cd12a /src/DotNetOpenAuth.Test/TestBase.cs | |
parent | 579703ee02408e7d3cdd604aa263e95a6f1e49c3 (diff) | |
download | DotNetOpenAuth-4c432c1278f301c3c80097866accca679e929fed.zip DotNetOpenAuth-4c432c1278f301c3c80097866accca679e929fed.tar.gz DotNetOpenAuth-4c432c1278f301c3c80097866accca679e929fed.tar.bz2 |
Fixes remaining build breaks.
Diffstat (limited to 'src/DotNetOpenAuth.Test/TestBase.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/TestBase.cs | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/DotNetOpenAuth.Test/TestBase.cs b/src/DotNetOpenAuth.Test/TestBase.cs index 875af7a..96ce98d 100644 --- a/src/DotNetOpenAuth.Test/TestBase.cs +++ b/src/DotNetOpenAuth.Test/TestBase.cs @@ -114,45 +114,52 @@ namespace DotNetOpenAuth.Test { new HttpResponse(new StringWriter())); } - protected internal static Task RunAsync(Func<IHostFactories, CancellationToken, Task> driver, params Handler[] handlers) { - var coordinator = new CoordinatorBase(driver, handlers); - return coordinator.RunAsync(); + protected internal Handler Handle(string uri) { + return new Handler(this, new Uri(uri)); } - protected internal static Handler Handle(Uri uri) { - return new Handler(uri); + protected internal Handler Handle(Uri uri) { + return new Handler(this, uri); } protected internal struct Handler { - internal Handler(Uri uri) + private TestBase test; + + internal Handler(TestBase test, Uri uri) : this() { + this.test = test; this.Uri = uri; } - public Uri Uri { get; private set; } + private Handler(Handler previous, Func<HttpRequestMessage, Task<HttpResponseMessage>> handler) + : this(previous.test, previous.Uri) { + this.MessageHandler = handler; + } + + internal Uri Uri { get; private set; } - public Func<IHostFactories, HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> MessageHandler { get; private set; } + internal Func<HttpRequestMessage, Task<HttpResponseMessage>> MessageHandler { get; private set; } - internal Handler By(Func<IHostFactories, HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> handler) { - return new Handler(this.Uri) { MessageHandler = handler }; + internal void By(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> handler) { + this.test.HostFactories.Handlers.Add(new Handler(this, req => handler(req, CancellationToken.None))); } - internal Handler By(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> handler) { - return this.By((hf, req, ct) => handler(req, ct)); + internal void By(Func<HttpRequestMessage, Task<HttpResponseMessage>> handler) { + this.test.HostFactories.Handlers.Add(new Handler(this, handler)); } - internal Handler By(Func<HttpRequestMessage, HttpResponseMessage> handler) { - return this.By((req, ct) => Task.FromResult(handler(req))); + internal void By(Func<HttpRequestMessage, HttpResponseMessage> handler) { + this.By(req => Task.FromResult(handler(req))); } - internal Handler By(string responseContent, string contentType, HttpStatusCode statusCode = HttpStatusCode.OK) { - return this.By( - req => { - var response = new HttpResponseMessage(statusCode); - response.Content = new StringContent(responseContent); - response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); - return response; - }); + internal void By(string responseContent, string contentType, HttpStatusCode statusCode = HttpStatusCode.OK) { + this.By( + req => { + var response = new HttpResponseMessage(statusCode); + response.Content = new StringContent(responseContent); + response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); + return response; + }); } } } |