Skip to content

Commit 40f0881

Browse files
author
Timothy Mothra
authored
fix DiagnoisticsEventThrottlingManagerTest (#1238)
1 parent eab1754 commit 40f0881

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingManagerTest.cs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using Mocks;
1010

1111
[TestClass]
12-
public sealed class DiagnoisticsEventThrottlingManagerTest : IDisposable
12+
public sealed class DiagnoisticsEventThrottlingManagerTest
1313
{
1414
private const uint SampleIntervalInMinutes = 10;
1515

@@ -19,27 +19,36 @@ public sealed class DiagnoisticsEventThrottlingManagerTest : IDisposable
1919
private const int ThrottlingStartedEventId = 4;
2020
private const int ThrottlingResetEventId = 5;
2121

22-
private readonly DiagnoisticsEventThrottlingMock throttleAllContainer = new DiagnoisticsEventThrottlingMock(
23-
throttleAll: true,
24-
signalJustExceeded: true,
25-
sampleCounters: new Dictionary<int, DiagnoisticsEventCounters>());
22+
private DiagnoisticsEventThrottlingMock throttleAllContainer;
2623

27-
private readonly DiagnoisticsEventThrottlingMock notThrottleContainer = new DiagnoisticsEventThrottlingMock(
28-
throttleAll: false,
29-
signalJustExceeded: false,
30-
sampleCounters: new Dictionary<int, DiagnoisticsEventCounters>());
24+
private DiagnoisticsEventThrottlingMock notThrottleContainer;
3125

32-
private readonly DiagnoisticsEventThrottlingSchedulerMock scheduler = new DiagnoisticsEventThrottlingSchedulerMock();
26+
private DiagnoisticsEventThrottlingSchedulerMock scheduler;
3327

34-
private readonly DiagnoisticsEventThrottlingManager<DiagnoisticsEventThrottlingMock> throttleFirstCallManager;
35-
private readonly DiagnoisticsEventThrottlingManager<DiagnoisticsEventThrottlingMock> notThrottleManager;
28+
private DiagnoisticsEventThrottlingManager<DiagnoisticsEventThrottlingMock> throttleFirstCallManager;
29+
private DiagnoisticsEventThrottlingManager<DiagnoisticsEventThrottlingMock> notThrottleManager;
3630

37-
private readonly DiagnosticsEventCollectingMock sender = new DiagnosticsEventCollectingMock();
31+
private DiagnosticsEventCollectingMock sender;
3832

39-
private readonly DiagnosticsListener listener;
40-
41-
public DiagnoisticsEventThrottlingManagerTest()
33+
private DiagnosticsListener listener;
34+
35+
[TestInitialize]
36+
public void TestInitialize()
4237
{
38+
this.throttleAllContainer = new DiagnoisticsEventThrottlingMock(
39+
throttleAll: true,
40+
signalJustExceeded: true,
41+
sampleCounters: new Dictionary<int, DiagnoisticsEventCounters>());
42+
43+
this.notThrottleContainer = new DiagnoisticsEventThrottlingMock(
44+
throttleAll: false,
45+
signalJustExceeded: false,
46+
sampleCounters: new Dictionary<int, DiagnoisticsEventCounters>());
47+
48+
this.scheduler = new DiagnoisticsEventThrottlingSchedulerMock();
49+
50+
this.sender = new DiagnosticsEventCollectingMock();
51+
4352
this.throttleFirstCallManager = new DiagnoisticsEventThrottlingManager<DiagnoisticsEventThrottlingMock>(
4453
this.throttleAllContainer,
4554
this.scheduler,
@@ -55,7 +64,8 @@ public DiagnoisticsEventThrottlingManagerTest()
5564
this.listener.LogLevel = EventLevel.Verbose;
5665
}
5766

58-
public void Dispose()
67+
[TestCleanup]
68+
public void TestCleanup()
5969
{
6070
this.listener.Dispose();
6171
}

0 commit comments

Comments
 (0)