Skip to content

Commit f8b29af

Browse files
authored
Use ManualResetEventSlim for waithandle in tests (+increase timeout) (#255)
* Use ManualResetEventSlim for waithandle in tests * Bump delay
1 parent b81c79e commit f8b29af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

test/Exceptionless.Tests/Storage/PersistedDictionaryTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void WillBeSaved() {
1515
dict.Saved += (sender, args) => resetEvent.Set();
1616
dict["test"] = "test";
1717
Assert.Equal("test", dict["test"]);
18-
bool success = resetEvent.WaitOne(250);
18+
bool success = resetEvent.WaitOne(500);
1919
Assert.True(success, "Failed to save dictionary.");
2020
Assert.True(storage.Exists("test.json"));
2121
}
@@ -29,14 +29,14 @@ public void WillSaveOnce() {
2929
for (int i = 0; i < 10; i++)
3030
dict["test" + i] = i.ToString();
3131
Assert.Equal(10, dict.Count);
32-
bool success = latch.Wait(250);
32+
bool success = latch.Wait(500);
3333
Assert.False(success, "Dictionary was saved multiple times.");
3434
Assert.Equal(1, latch.Remaining);
3535
Assert.True(storage.Exists("test.json"));
3636

3737
dict["test"] = "test";
3838
Assert.Equal(11, dict.Count);
39-
success = latch.Wait(250);
39+
success = latch.Wait(500);
4040
Assert.True(success, "Failed to save dictionary.");
4141
Assert.True(storage.Exists("test.json"));
4242
}

test/Exceptionless.Tests/Utility/CountDownLatch.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Exceptionless.Tests.Utility {
55
public class CountDownLatch {
66
private int _remaining;
7-
private EventWaitHandle _event;
7+
private ManualResetEventSlim _event;
88

99
public CountDownLatch(int count) {
1010
Reset(count);
@@ -14,7 +14,7 @@ public void Reset(int count) {
1414
if (count < 0)
1515
throw new ArgumentOutOfRangeException();
1616
_remaining = count;
17-
_event = new ManualResetEvent(false);
17+
_event = new ManualResetEventSlim(false);
1818
if (_remaining == 0)
1919
_event.Set();
2020
}
@@ -26,7 +26,7 @@ public void Signal() {
2626
}
2727

2828
public bool Wait(int millisecondsTimeout) {
29-
return _event.WaitOne(millisecondsTimeout);
29+
return _event.Wait(millisecondsTimeout);
3030
}
3131

3232
public int Remaining { get { return _remaining; } }

0 commit comments

Comments
 (0)