summaryrefslogtreecommitdiffstats
path: root/tests/TinyPng.Tests/FakeResponseHandler.cs
diff options
context:
space:
mode:
authorChad T <chad@tolkien.id.au>2017-04-25 10:43:58 +1000
committerGitHub <noreply@github.com>2017-04-25 10:43:58 +1000
commit05da6905fac19035a78a7946d1cf0403043c5b22 (patch)
tree603b17f4897eeb8b803f10593b28877420b6e469 /tests/TinyPng.Tests/FakeResponseHandler.cs
parent8213c3425c799ea5b79305cb20ef51adbd5aa97d (diff)
downloadTinyPNG-origin/release.zip
TinyPNG-origin/release.tar.gz
TinyPNG-origin/release.tar.bz2
Merging in for V3 release (#18)origin/release
* fixed errors in the readme * Deleted ncrunch bits. * Add ncrunch to gitignore * appveyor WIP * appveyor wip * appveyor wip * AV has bash?! * appveyor wip * added badge to readme * appveyor wip * appveyor.yml wip * appveyor wip, don't run tests twice * appveyor last time! * test improvements #1 * more test coverage * more test coverage * more testing, resize operations * exception tests * yet more tests * test improvements #1 (#13) * test improvements #1 * more test coverage * more test coverage * more testing, resize operations * exception tests * yet more tests * tests * actually builds * on the round to 100% * fixed final failing test * fixed code which would generate stack overflow exceptions.. woops * Delete build.sh * Update .travis.yml * Update .travis.yml * Update .travis.yml * Dropping OSX CI builds * Update README.md * Version 3 release (#14) * refactored the api * updating readme * internalsvisibleto * make httpclient static * WIP * cleanup * further cleanup * Final update to readme * add test for non success on compress operation * increase test coverage * Remove package.json, unneeded * CSProj migration (#16) * migrating to csproj * Appveyor * appveyor * cleanup csprojs * ditched assembly info * av * av * av * travis * travis * fix AV * fix AV * include resources to output * include resources to output * project json accidentaly made a return * update version * killed off xproj * v3 refactor * test open cover * opencover * opencover * yet more travis work * spell language correctly * can we get mac builds * travis * travis * travis * travis * remove sudo * Use 2017 release image on AV
Diffstat (limited to 'tests/TinyPng.Tests/FakeResponseHandler.cs')
-rw-r--r--tests/TinyPng.Tests/FakeResponseHandler.cs84
1 files changed, 43 insertions, 41 deletions
diff --git a/tests/TinyPng.Tests/FakeResponseHandler.cs b/tests/TinyPng.Tests/FakeResponseHandler.cs
index 98ddec2..7fb8c07 100644
--- a/tests/TinyPng.Tests/FakeResponseHandler.cs
+++ b/tests/TinyPng.Tests/FakeResponseHandler.cs
@@ -1,41 +1,43 @@
-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 };
- }
-
- }
- }
-}
+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);
+ }
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
+ {
+ 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 };
+ }
+
+ }
+ }
+}