-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
massive refactor to support mocked http requests
- Loading branch information
Showing
14 changed files
with
236 additions
and
47 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
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,14 @@ | ||
<SolutionConfiguration> | ||
<FileVersion>1</FileVersion> | ||
<InferProjectReferencesUsingAssemblyNames>false</InferProjectReferencesUsingAssemblyNames> | ||
<AllowParallelTestExecution>false</AllowParallelTestExecution> | ||
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves> | ||
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit> | ||
<FrameworkUtilisationTypeForGallio>UseStaticAnalysis</FrameworkUtilisationTypeForGallio> | ||
<FrameworkUtilisationTypeForMSpec>UseStaticAnalysis</FrameworkUtilisationTypeForMSpec> | ||
<FrameworkUtilisationTypeForMSTest>UseStaticAnalysis</FrameworkUtilisationTypeForMSTest> | ||
<FrameworkUtilisationTypeForXUnit2>UseDynamicAnalysis</FrameworkUtilisationTypeForXUnit2> | ||
<NCrunchCacheStoragePath /> | ||
<MetricsExclusionList> | ||
</MetricsExclusionList> | ||
</SolutionConfiguration> |
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,14 @@ | ||
using System.Net.Http; | ||
|
||
namespace TinyPng.Responses | ||
{ | ||
/// <summary> | ||
/// This is a response which contains actual image data | ||
/// </summary> | ||
public class TinyPngImageResponse : TinyPngResponse | ||
{ | ||
public TinyPngImageResponse(HttpResponseMessage msg) : base(msg) | ||
{ | ||
} | ||
} | ||
} |
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
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,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace TinyPng.Tests | ||
{ | ||
public class FakeResponseHandler : DelegatingHandler | ||
{ | ||
private readonly Dictionary<Uri, HttpResponseMessage> _FakeGetResponses = new Dictionary<Uri, HttpResponseMessage>(); | ||
private readonly Dictionary<Uri, HttpResponseMessage> _FakePostResponses = new Dictionary<Uri, HttpResponseMessage>(); | ||
|
||
|
||
public void AddFakeGetResponse(Uri uri, HttpResponseMessage responseMessage) | ||
{ | ||
_FakeGetResponses.Add(uri, responseMessage); | ||
} | ||
public void AddFakePostResponse(Uri uri, HttpResponseMessage responseMessage) | ||
{ | ||
_FakePostResponses.Add(uri, responseMessage); | ||
} | ||
|
||
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) | ||
{ | ||
if (request.Method == HttpMethod.Get && _FakeGetResponses.ContainsKey(request.RequestUri)) | ||
{ | ||
return _FakeGetResponses[request.RequestUri]; | ||
} | ||
if (request.Method == HttpMethod.Post &&_FakePostResponses.ContainsKey(request.RequestUri)) | ||
{ | ||
return _FakePostResponses[request.RequestUri]; | ||
} | ||
else | ||
{ | ||
return new HttpResponseMessage(HttpStatusCode.NotFound) { RequestMessage = request }; | ||
} | ||
|
||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.