Skip to content

Commit 0c1e767

Browse files
committed
Fix warnings and upgrade dotnet-tools
1 parent 419822d commit 0c1e767

File tree

10 files changed

+29
-13
lines changed

10 files changed

+29
-13
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"nbgv": {
6-
"version": "3.7.115",
6+
"version": "3.9.50",
77
"commands": [
88
"nbgv"
99
],

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@ dotnet_style_namespace_match_folder = true
9494

9595
# CA1303: Do not pass literals as localized parameters
9696
dotnet_diagnostic.CA1303.severity = silent
97+
98+
# IDE0060: Remove unused parameter
99+
dotnet_diagnostic.IDE0060.severity = silent

src/TestableHttpClient/IHttpRequestMessagesCheck.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ public interface IHttpRequestMessagesCheck
88
/// <summary>
99
/// Options that could be used by several asserters.
1010
/// </summary>
11-
TestableHttpMessageHandlerOptions Options { get; }
11+
public TestableHttpMessageHandlerOptions Options { get; }
1212

1313
/// <summary>
1414
/// Asserts whether requests comply with a specific filter.
1515
/// </summary>
1616
/// <param name="requestFilter">The filter to filter requests with before asserting.</param>
1717
/// <param name="condition">The name of the condition, used in the exception message.</param>
1818
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
19-
IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, string condition);
19+
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, string condition);
2020

2121
/// <summary>
2222
/// Asserts whether requests comply with a specific filter.
@@ -25,7 +25,7 @@ public interface IHttpRequestMessagesCheck
2525
/// <param name="expectedNumberOfRequests">The expected number of requests.</param>
2626
/// <param name="condition">The name of the condition, used in the exception message.</param>
2727
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
28-
IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, int expectedNumberOfRequests, string condition);
28+
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, int expectedNumberOfRequests, string condition);
2929

3030
/// <summary>
3131
/// Asserts whether requests comply with a specific filter.
@@ -34,5 +34,5 @@ public interface IHttpRequestMessagesCheck
3434
/// <param name="expectedNumberOfRequests">The expected number of requests, when null is passed "at least one" is presumed.</param>
3535
/// <param name="condition">The name of the condition, used in the exception message.</param>
3636
/// <returns>The <seealso cref="IHttpRequestMessagesCheck"/> for further assertions.</returns>
37-
IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, int? expectedNumberOfRequests, string condition);
37+
public IHttpRequestMessagesCheck WithFilter(Func<HttpRequestMessage, bool> requestFilter, int? expectedNumberOfRequests, string condition);
3838
}

src/TestableHttpClient/IResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public interface IResponse
1111
/// <param name="context">The context for this request.</param>
1212
/// <param name="cancellationToken">The cancellationToken.</param>
1313
/// <returns></returns>
14-
Task ExecuteAsync(HttpResponseContext context, CancellationToken cancellationToken);
14+
public Task ExecuteAsync(HttpResponseContext context, CancellationToken cancellationToken);
1515
}

src/TestableHttpClient/IRoutingResponseBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public interface IRoutingResponseBuilder
1111
/// <param name="route">The route pattern.</param>
1212
/// <param name="response">The response the route should return.</param>
1313
/// <example>x.Map("*", Responses.StatusCode(HttpStatusCode.OK))</example>
14-
void Map(string route, IResponse response);
14+
public void Map(string route, IResponse response);
1515
/// <summary>
1616
/// Maps a custom response for when a request didn't match any route. Defaults to Responses.StatusCode(HttpStatusCode.NotFound).
1717
/// </summary>
1818
/// <param name="fallBackResponse">The response that should be returned when no route matches.</param>
19-
void MapFallBackResponse(IResponse fallBackResponse);
19+
public void MapFallBackResponse(IResponse fallBackResponse);
2020
}

src/TestableHttpClient/Response/RoutingResponse.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using static TestableHttpClient.Responses;
33

44
namespace TestableHttpClient.Response;
5+
56
internal sealed class RoutingResponse : IResponse
67
{
78
public Task ExecuteAsync(HttpResponseContext context, CancellationToken cancellationToken)

src/TestableHttpClient/TestableHttpClient.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
</PropertyGroup>
3333

3434
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
35-
<PackageReference Include="System.Net.Http" Version="4.3.4" />
3635
<PackageReference Include="System.Text.Json" Version="4.7.2" />
3736
<PackageReference Include="System.Text.Encodings.Web" Version="4.7.2" />
3837
<PackageReference Include="Perfors.UnreachableException" Version="1.0.0" />

test/TestableHttpClient.IntegrationTests/CustomizeJsonSerialization.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ public async Task ByDefault_CamelCasing_is_used_for_json_serialization()
1414
sut.RespondWith(Json(new { Name = "Charlie" }));
1515
using HttpClient client = sut.CreateClient();
1616

17+
#if NETFRAMEWORK
1718
string json = await client.GetStringAsync("http://localhost/myjson");
19+
#else
20+
string json = await client.GetStringAsync("http://localhost/myjson", TestContext.Current.CancellationToken);
21+
#endif
1822

1923
Assert.Equal("{\"name\":\"Charlie\"}", json);
2024
}
@@ -27,7 +31,11 @@ public async Task But_this_can_be_changed()
2731
sut.RespondWith(Json(new { Name = "Charlie" }));
2832
using HttpClient client = sut.CreateClient();
2933

34+
#if NETFRAMEWORK
3035
string json = await client.GetStringAsync("http://localhost/myjson");
36+
#else
37+
string json = await client.GetStringAsync("http://localhost/myjson", TestContext.Current.CancellationToken);
38+
#endif
3139

3240
Assert.Equal("{\"Name\":\"Charlie\"}", json);
3341
}
@@ -39,7 +47,11 @@ public async Task But_Also_directly_on_the_response()
3947
sut.RespondWith(Json(new { Name = "Charlie" }, jsonSerializerOptions: new JsonSerializerOptions()));
4048
using HttpClient client = sut.CreateClient();
4149

50+
#if NETFRAMEWORK
4251
string json = await client.GetStringAsync("http://localhost/myjson");
52+
#else
53+
string json = await client.GetStringAsync("http://localhost/myjson", TestContext.Current.CancellationToken);
54+
#endif
4355

4456
Assert.Equal("{\"Name\":\"Charlie\"}", json);
4557
}

test/TestableHttpClient.Tests/Response/ResponseTestHelpers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
internal static class ResponseTestHelpers
44
{
55
public static Task<HttpResponseMessage> TestAsync(this IResponse response) => TestAsync(response, "http://httpbin.org");
6-
public static Task<HttpResponseMessage> TestAsync(this IResponse response, string url)
6+
public static async Task<HttpResponseMessage> TestAsync(this IResponse response, string url)
77
{
88
using TestableHttpMessageHandler handler = new();
99
handler.RespondWith(response);
10-
return handler.TestAsync(url);
10+
return await handler.TestAsync(url);
1111
}
1212

1313
public static Task<HttpResponseMessage> TestAsync(this TestableHttpMessageHandler handler) => TestAsync(handler, "http://httpbin.org");
14-
public static Task<HttpResponseMessage> TestAsync(this TestableHttpMessageHandler handler, string url)
14+
public static async Task<HttpResponseMessage> TestAsync(this TestableHttpMessageHandler handler, string url)
1515
{
1616
using HttpClient client = new(handler);
17-
return client.GetAsync(url);
17+
return await client.GetAsync(url);
1818
}
1919
}

test/TestableHttpClient.Tests/Utils/UriPatternParserTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using TestableHttpClient.Utils;
22

33
namespace TestableHttpClient.Tests.Utils;
4+
45
public class UriPatternParserTests
56
{
67
[Theory]

0 commit comments

Comments
 (0)