-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathCancellationSourceTests.cs
More file actions
38 lines (31 loc) · 945 Bytes
/
CancellationSourceTests.cs
File metadata and controls
38 lines (31 loc) · 945 Bytes
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
using System.Threading;
using FluentAssertions;
using Godot;
using GodotSharp.BuildingBlocks.TestRunner;
namespace GodotTests.TestScenes;
[SceneTree]
[CancellationSource]
public partial class CancellationSourceTests : Node, ITest
{
private CancellationToken capturedToken;
void ITest.InitTests()
{
Cts.Should().BeNull();
}
void ITest.EnterTests()
{
// After entering tree, CTS should be created
Cts.Should().NotBeNull();
Cts.Token.IsCancellationRequested.Should().BeFalse();
Cts.Token.CanBeCanceled.Should().BeTrue();
// Capture token to verify it gets cancelled on exit
capturedToken = Cts.Token;
}
void ITest.ExitTests()
{
// After exiting tree, the captured token should be cancelled
capturedToken.IsCancellationRequested.Should().BeTrue();
// The property should now return null
Cts.Should().BeNull();
}
}