Skip to content

Commit

Permalink
.net8
Browse files Browse the repository at this point in the history
  • Loading branch information
ctolkien committed May 16, 2024
1 parent 986a508 commit 4174d01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions tests/TinyPng.Tests/FakeResponseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace TinyPng.Tests;

public class FakeResponseHandler : DelegatingHandler
{
private readonly Dictionary<Uri, HttpResponseMessage> _fakeGetResponses = new();
private readonly Dictionary<Uri, HttpResponseMessage> _fakePostResponses = new();
private readonly Dictionary<Uri, HttpResponseMessage> _fakeGetResponses = [];
private readonly Dictionary<Uri, HttpResponseMessage> _fakePostResponses = [];


public void AddFakeGetResponse(Uri uri, HttpResponseMessage responseMessage)
Expand All @@ -23,12 +23,8 @@ public void AddFakePostResponse(Uri uri, HttpResponseMessage responseMessage)

protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
var result = request.Method == HttpMethod.Get && _fakeGetResponses.ContainsKey(request.RequestUri)
? _fakeGetResponses[request.RequestUri]
: request.Method == HttpMethod.Post && _fakePostResponses.ContainsKey(request.RequestUri)
? _fakePostResponses[request.RequestUri]
: new HttpResponseMessage(HttpStatusCode.NotFound) { RequestMessage = request };

return Task.FromResult(result);
if (request.Method == HttpMethod.Get && _fakeGetResponses.TryGetValue(request.RequestUri, out var getMessage)) { return Task.FromResult(getMessage); }
else if (request.Method == HttpMethod.Post && _fakePostResponses.TryGetValue(request.RequestUri, out var postMessage)) { return Task.FromResult(postMessage); }
else { return Task.FromResult(new HttpResponseMessage(HttpStatusCode.NotFound) { RequestMessage = request }); }
}
}
2 changes: 1 addition & 1 deletion tests/TinyPng.Tests/TinyPng.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\TinyPNG\TinyPNG.csproj" />
Expand Down

0 comments on commit 4174d01

Please sign in to comment.