-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBoundedCleanupTests.cs
More file actions
39 lines (33 loc) · 1.19 KB
/
BoundedCleanupTests.cs
File metadata and controls
39 lines (33 loc) · 1.19 KB
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
namespace DotPilot.UITests;
[TestFixture]
public sealed class BoundedCleanupTests
{
private const string CleanupOperationName = "test cleanup";
private static readonly TimeSpan Timeout = TimeSpan.FromMilliseconds(50);
[Test]
public void WhenCleanupCompletesWithinTimeoutThenItSucceeds()
{
BoundedCleanup.Run(static () => { }, Timeout, CleanupOperationName);
}
[Test]
public void WhenCleanupThrowsThenItWrapsTheFailure()
{
var exception = Assert.Throws<InvalidOperationException>(
() => BoundedCleanup.Run(
static () => throw new InvalidOperationException("boom"),
Timeout,
CleanupOperationName));
Assert.That(exception, Is.Not.Null);
Assert.That(exception!.InnerException, Is.TypeOf<InvalidOperationException>());
}
[Test]
public void WhenCleanupTimesOutThenItFailsFast()
{
var exception = Assert.Throws<TimeoutException>(
() => BoundedCleanup.Run(
static () => Thread.Sleep(System.Threading.Timeout.Infinite),
Timeout,
CleanupOperationName));
Assert.That(exception, Is.Not.Null);
}
}