-
Notifications
You must be signed in to change notification settings - Fork 1
/
IntegrationTest.cs
64 lines (56 loc) · 1.82 KB
/
IntegrationTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) Martin Costello, 2016. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
namespace MartinCostello.Website.Integration;
/// <summary>
/// The base class for integration tests.
/// </summary>
[Collection(TestServerCollection.Name)]
public abstract class IntegrationTest : IDisposable
{
private bool _disposed;
/// <summary>
/// Initializes a new instance of the <see cref="IntegrationTest"/> class.
/// </summary>
/// <param name="fixture">The fixture to use.</param>
/// <param name="outputHelper">The test output helper to use.</param>
protected IntegrationTest(TestServerFixture fixture, ITestOutputHelper outputHelper)
{
Fixture = fixture;
Fixture.SetOutputHelper(outputHelper);
}
/// <summary>
/// Finalizes an instance of the <see cref="IntegrationTest"/> class.
/// </summary>
~IntegrationTest()
{
Dispose(false);
}
/// <summary>
/// Gets the <see cref="TestServerFixture"/> to use.
/// </summary>
protected TestServerFixture Fixture { get; }
/// <inheritdoc />
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <param name="disposing">
/// <see langword="true" /> to release both managed and unmanaged resources;
/// <see langword="false" /> to release only unmanaged resources.
/// </param>
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
Fixture?.ClearOutputHelper();
}
_disposed = true;
}
}
}