Skip to content

Commit ab7aa7e

Browse files
author
Bart Koelman
committed
Resource management
1 parent 8a0657a commit ab7aa7e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public async Task Get_skips_middleware_and_formatters()
2323
// Arrange
2424
using var request = new HttpRequestMessage(HttpMethod.Get, "/NonJsonApi");
2525

26-
HttpClient client = _testContext.Factory.CreateClient();
26+
using HttpClient client = _testContext.Factory.CreateClient();
2727

2828
// Act
29-
HttpResponseMessage httpResponse = await client.SendAsync(request);
29+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
3030

3131
// Assert
3232
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -52,10 +52,10 @@ public async Task Post_skips_middleware_and_formatters()
5252
}
5353
};
5454

55-
HttpClient client = _testContext.Factory.CreateClient();
55+
using HttpClient client = _testContext.Factory.CreateClient();
5656

5757
// Act
58-
HttpResponseMessage httpResponse = await client.SendAsync(request);
58+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
5959

6060
// Assert
6161
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -72,10 +72,10 @@ public async Task Post_skips_error_handler()
7272
// Arrange
7373
using var request = new HttpRequestMessage(HttpMethod.Post, "/NonJsonApi");
7474

75-
HttpClient client = _testContext.Factory.CreateClient();
75+
using HttpClient client = _testContext.Factory.CreateClient();
7676

7777
// Act
78-
HttpResponseMessage httpResponse = await client.SendAsync(request);
78+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
7979

8080
// Assert
8181
httpResponse.Should().HaveStatusCode(HttpStatusCode.BadRequest);
@@ -101,10 +101,10 @@ public async Task Put_skips_middleware_and_formatters()
101101
}
102102
};
103103

104-
HttpClient client = _testContext.Factory.CreateClient();
104+
using HttpClient client = _testContext.Factory.CreateClient();
105105

106106
// Act
107-
HttpResponseMessage httpResponse = await client.SendAsync(request);
107+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
108108

109109
// Assert
110110
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -121,10 +121,10 @@ public async Task Patch_skips_middleware_and_formatters()
121121
// Arrange
122122
using var request = new HttpRequestMessage(HttpMethod.Patch, "/NonJsonApi?name=Janice");
123123

124-
HttpClient client = _testContext.Factory.CreateClient();
124+
using HttpClient client = _testContext.Factory.CreateClient();
125125

126126
// Act
127-
HttpResponseMessage httpResponse = await client.SendAsync(request);
127+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
128128

129129
// Assert
130130
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -141,10 +141,10 @@ public async Task Delete_skips_middleware_and_formatters()
141141
// Arrange
142142
using var request = new HttpRequestMessage(HttpMethod.Delete, "/NonJsonApi");
143143

144-
HttpClient client = _testContext.Factory.CreateClient();
144+
using HttpClient client = _testContext.Factory.CreateClient();
145145

146146
// Act
147-
HttpResponseMessage httpResponse = await client.SendAsync(request);
147+
using HttpResponseMessage httpResponse = await client.SendAsync(request);
148148

149149
// Assert
150150
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);

0 commit comments

Comments
 (0)