Skip to content

Commit 3cbf5e1

Browse files
committed
Adding proper disposal to test fixture
1 parent a5adf43 commit 3cbf5e1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/WebJobs.Script.Tests.Integration/ApplicationInsights/ApplicationInsightsTestFixture.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
namespace Microsoft.Azure.WebJobs.Script.Tests.ApplicationInsights
1818
{
19-
public abstract class ApplicationInsightsTestFixture
19+
public abstract class ApplicationInsightsTestFixture : IDisposable
2020
{
2121
private readonly ScriptSettingsManager _settingsManager;
2222
private readonly HttpConfiguration _config = new HttpConfiguration();
23+
private readonly HttpServer _httpServer;
2324

2425
public ApplicationInsightsTestFixture(string scriptRoot, string testId)
2526
{
@@ -43,8 +44,8 @@ public ApplicationInsightsTestFixture(string scriptRoot, string testId)
4344

4445
InitializeConfig(hostConfig);
4546

46-
var httpServer = new HttpServer(_config);
47-
HttpClient = new HttpClient(httpServer)
47+
_httpServer = new HttpServer(_config);
48+
HttpClient = new HttpClient(_httpServer)
4849
{
4950
BaseAddress = new Uri("https://localhost/")
5051
};
@@ -70,6 +71,12 @@ protected void InitializeConfig(ScriptHostConfiguration config)
7071
};
7172
}
7273

74+
public void Dispose()
75+
{
76+
_httpServer?.Dispose();
77+
HttpClient?.Dispose();
78+
}
79+
7380
private class TestLoggerFactoryBuilder : DefaultLoggerFactoryBuilder
7481
{
7582
private readonly TestTelemetryChannel _channel;

0 commit comments

Comments
 (0)