com.valectric.mooserunner 2.1.21 → 2.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +23 -23
  2. package/CLI~/mooserunnerCli.exe +0 -0
  3. package/CLI~/mooserunnerCliDaemon.exe +0 -0
  4. package/Editor/HotReloadIntegration/MooseRunner.HotReloadIntegration.dll +0 -0
  5. package/Editor/HotReloadIntegration/MooseRunner.HotReloadIntegration.dll.meta +32 -32
  6. package/Editor/MooseRunner.Editor.asmdef +15 -15
  7. package/Editor/MooseRunner.Editor.asmdef.meta +6 -6
  8. package/Editor/MooseRunner.Internal.Editor.dll +0 -0
  9. package/Editor/MooseRunner.Internal.Editor.dll.meta +32 -32
  10. package/Editor/MooseRunner.Worker.dll +0 -0
  11. package/Editor/MooseRunner.Worker.dll.meta +32 -32
  12. package/Editor/SessionRecorder/MooseRunner.SessionRecorder.dll +0 -0
  13. package/Editor/SessionRecorder/MooseRunner.SessionRecorder.dll.meta +32 -32
  14. package/Editor/_WrapperStub.cs.meta +10 -10
  15. package/LICENSE.md +28 -28
  16. package/Runtime/MooseRunner.Helpers.Runtime.dll +0 -0
  17. package/Runtime/MooseRunner.Helpers.Runtime.dll.meta +26 -26
  18. package/Runtime/MooseRunner.Internal.dll +0 -0
  19. package/Runtime/MooseRunner.Internal.dll.meta +26 -26
  20. package/Runtime/MooseRunner.Multiplaytest.Types.dll +0 -0
  21. package/Runtime/MooseRunner.Multiplaytest.Types.dll.meta +26 -26
  22. package/Runtime/MooseRunner.Runtime.asmdef +15 -15
  23. package/Runtime/MooseRunner.Runtime.asmdef.meta +6 -6
  24. package/Runtime/MooseRunner.SessionRecorder.Public.dll +0 -0
  25. package/Runtime/MooseRunner.SessionRecorder.Public.dll.meta +26 -26
  26. package/Runtime/MooseRunner.SessionRecorder.Runtime.dll +0 -0
  27. package/Runtime/MooseRunner.SessionRecorder.Runtime.dll.meta +26 -26
  28. package/Runtime/MooseRunner.dll +0 -0
  29. package/Runtime/MooseRunner.dll.meta +26 -26
  30. package/Runtime/_WrapperStub.cs.meta +10 -10
  31. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/BatchCancellationTests.cs +37 -37
  32. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/CancellationTokenTests.cs +186 -186
  33. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/SetupTeardownCancellationTests.cs +85 -85
  34. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogEntry.cs +51 -51
  35. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogFileParser.cs +69 -69
  36. package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MethodOrderAttributeTests.cs +62 -62
  37. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Enemy.cs +100 -100
  38. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/FireComponent.cs +18 -18
  39. package/Samples~/Demos/MooseRunner.Demo.Support/MessageDisplayManager.cs +291 -291
  40. package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunnerSampleVersionCheck.cs +57 -57
  41. package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunnerSampleVersionCheck.cs.meta +1 -1
  42. package/Samples~/Demos/MooseRunner.Demo.Tests/ExplicitAttributeTests.cs +36 -36
  43. package/Samples~/Demos/MooseRunner.Demo.Tests/InstanceHandlingVerificationTest.cs +99 -99
  44. package/Third Party Notices.md +37 -37
  45. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- fileFormatVersion: 2
2
- guid: 154da65fc8cec2259df683ae57a5c364
3
- AssemblyDefinitionImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
1
+ fileFormatVersion: 2
2
+ guid: 154da65fc8cec2259df683ae57a5c364
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
7
  assetBundleVariant:
@@ -1,27 +1,27 @@
1
- fileFormatVersion: 2
2
- guid: 70a3dbbdc7c92a81a1540262a7f14bfd
3
- PluginImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- iconMap: {}
7
- executionOrder: {}
8
- defineConstraints: []
9
- isPreloaded: 0
10
- isOverridable: 1
11
- isExplicitlyReferenced: 0
12
- validateReferences: 0
13
- platformData:
14
- - first:
15
- Any:
16
- second:
17
- enabled: 1
18
- settings: {}
19
- - first:
20
- Editor: Editor
21
- second:
22
- enabled: 1
23
- settings:
24
- DefaultValueInitialized: true
25
- userData:
26
- assetBundleName:
1
+ fileFormatVersion: 2
2
+ guid: 70a3dbbdc7c92a81a1540262a7f14bfd
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 0
13
+ platformData:
14
+ - first:
15
+ Any:
16
+ second:
17
+ enabled: 1
18
+ settings: {}
19
+ - first:
20
+ Editor: Editor
21
+ second:
22
+ enabled: 1
23
+ settings:
24
+ DefaultValueInitialized: true
25
+ userData:
26
+ assetBundleName:
27
27
  assetBundleVariant:
@@ -1,27 +1,27 @@
1
- fileFormatVersion: 2
2
- guid: dafaa6afaa82bbea1976f16c7db3a56e
3
- PluginImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- iconMap: {}
7
- executionOrder: {}
8
- defineConstraints: []
9
- isPreloaded: 0
10
- isOverridable: 1
11
- isExplicitlyReferenced: 0
12
- validateReferences: 0
13
- platformData:
14
- - first:
15
- Any:
16
- second:
17
- enabled: 1
18
- settings: {}
19
- - first:
20
- Editor: Editor
21
- second:
22
- enabled: 1
23
- settings:
24
- DefaultValueInitialized: true
25
- userData:
26
- assetBundleName:
1
+ fileFormatVersion: 2
2
+ guid: dafaa6afaa82bbea1976f16c7db3a56e
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 0
13
+ platformData:
14
+ - first:
15
+ Any:
16
+ second:
17
+ enabled: 1
18
+ settings: {}
19
+ - first:
20
+ Editor: Editor
21
+ second:
22
+ enabled: 1
23
+ settings:
24
+ DefaultValueInitialized: true
25
+ userData:
26
+ assetBundleName:
27
27
  assetBundleVariant:
Binary file
@@ -1,27 +1,27 @@
1
- fileFormatVersion: 2
2
- guid: b96d0e212ba2c3bb16e19748561f5caf
3
- PluginImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- iconMap: {}
7
- executionOrder: {}
8
- defineConstraints: []
9
- isPreloaded: 0
10
- isOverridable: 1
11
- isExplicitlyReferenced: 0
12
- validateReferences: 0
13
- platformData:
14
- - first:
15
- Any:
16
- second:
17
- enabled: 1
18
- settings: {}
19
- - first:
20
- Editor: Editor
21
- second:
22
- enabled: 1
23
- settings:
24
- DefaultValueInitialized: true
25
- userData:
26
- assetBundleName:
1
+ fileFormatVersion: 2
2
+ guid: b96d0e212ba2c3bb16e19748561f5caf
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 0
13
+ platformData:
14
+ - first:
15
+ Any:
16
+ second:
17
+ enabled: 1
18
+ settings: {}
19
+ - first:
20
+ Editor: Editor
21
+ second:
22
+ enabled: 1
23
+ settings:
24
+ DefaultValueInitialized: true
25
+ userData:
26
+ assetBundleName:
27
27
  assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 0e44a1575f5377e400baa7ebcbe1e949
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
1
+ fileFormatVersion: 2
2
+ guid: 0e44a1575f5377e400baa7ebcbe1e949
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
11
  assetBundleVariant:
@@ -1,37 +1,37 @@
1
- using System.Threading;
2
- using System.Threading.Tasks;
3
- using UnityEngine;
4
- using UnityEngine.TestTools;
5
-
6
- namespace MooseRunner.Internal.Tests
7
- {
8
- /// <summary>
9
- /// Batch cancellation tests - run all 3 tests together to test batch stopping.
10
- /// </summary>
11
- public class BatchCancellationTests
12
- {
13
- [UnityTest]
14
- public async Task BatchTest1_TwoSeconds(CancellationToken ct)
15
- {
16
- Debug.Log("[Batch1] Starting 2-second test");
17
- await Task.Delay(2000, ct);
18
- Debug.Log("[Batch1] Completed");
19
- }
20
-
21
- [UnityTest]
22
- public async Task BatchTest2_TwoSeconds(CancellationToken ct)
23
- {
24
- Debug.Log("[Batch2] Starting 2-second test");
25
- await Task.Delay(2000, ct);
26
- Debug.Log("[Batch2] Completed");
27
- }
28
-
29
- [UnityTest]
30
- public async Task BatchTest3_TwoSeconds(CancellationToken ct)
31
- {
32
- Debug.Log("[Batch3] Starting 2-second test");
33
- await Task.Delay(2000, ct);
34
- Debug.Log("[Batch3] Completed");
35
- }
36
- }
37
- }
1
+ using System.Threading;
2
+ using System.Threading.Tasks;
3
+ using UnityEngine;
4
+ using UnityEngine.TestTools;
5
+
6
+ namespace MooseRunner.Internal.Tests
7
+ {
8
+ /// <summary>
9
+ /// Batch cancellation tests - run all 3 tests together to test batch stopping.
10
+ /// </summary>
11
+ public class BatchCancellationTests
12
+ {
13
+ [UnityTest]
14
+ public async Task BatchTest1_TwoSeconds(CancellationToken ct)
15
+ {
16
+ Debug.Log("[Batch1] Starting 2-second test");
17
+ await Task.Delay(2000, ct);
18
+ Debug.Log("[Batch1] Completed");
19
+ }
20
+
21
+ [UnityTest]
22
+ public async Task BatchTest2_TwoSeconds(CancellationToken ct)
23
+ {
24
+ Debug.Log("[Batch2] Starting 2-second test");
25
+ await Task.Delay(2000, ct);
26
+ Debug.Log("[Batch2] Completed");
27
+ }
28
+
29
+ [UnityTest]
30
+ public async Task BatchTest3_TwoSeconds(CancellationToken ct)
31
+ {
32
+ Debug.Log("[Batch3] Starting 2-second test");
33
+ await Task.Delay(2000, ct);
34
+ Debug.Log("[Batch3] Completed");
35
+ }
36
+ }
37
+ }
@@ -1,186 +1,186 @@
1
- using System;
2
- using System.Threading;
3
- using System.Threading.Tasks;
4
- using NUnit.Framework;
5
- using UnityEngine;
6
- using UnityEngine.TestTools;
7
-
8
- #if UNITASK_PRESENT
9
- using Cysharp.Threading.Tasks;
10
- #endif
11
-
12
- namespace MooseRunner.Internal.Tests
13
- {
14
- /// <summary>
15
- /// Tests to validate CancellationToken implementation in MooseRunner.
16
- /// These tests are designed for MANUAL testing - run them and click Stop button during execution.
17
- /// </summary>
18
- public class CancellationTokenTests
19
- {
20
- /// <summary>
21
- /// Test 1: Basic Task Cancellation
22
- /// Expected: When Stop is clicked, the test should cancel immediately and show "Test was cancelled" in console.
23
- /// NOTE: This test is designed for MANUAL testing. When run automatically, it WILL FAIL with Assert.Fail after 10 seconds.
24
- /// </summary>
25
- [UnityTest]
26
- public async Task Test1_BasicTaskCancellation_ShouldFail(CancellationToken ct)
27
- {
28
- Debug.Log("[Test1] Test started - will delay for 10 seconds");
29
- Debug.Log("[Test1] Click STOP button within 1-2 seconds to test cancellation!");
30
-
31
- try
32
- {
33
- await Task.Delay(10000, ct); // 10 second delay
34
- Assert.Fail("[Test1] Should not reach here if cancelled");
35
- }
36
- catch (OperationCanceledException)
37
- {
38
- Debug.Log("[Test1] SUCCESS: Cancellation was properly caught by test method");
39
- throw; // Re-throw so MooseRunner handles it
40
- }
41
- }
42
-
43
- /// <summary>
44
- /// Test 2: Cooperative Loop Cancellation
45
- /// Expected: Loop should exit immediately when Stop is clicked, remaining iterations should not execute.
46
- /// </summary>
47
- [UnityTest]
48
- public async Task Test2_CooperativeLoop_ShouldExitEarly(CancellationToken ct)
49
- {
50
- Debug.Log("[Test2] Starting 100 iterations - click STOP after ~5 iterations");
51
-
52
- for (int i = 0; i < 100; i++)
53
- {
54
- Debug.Log($"[Test2] Iteration {i}");
55
- await Task.Delay(100, ct);
56
- ct.ThrowIfCancellationRequested(); // Explicit check
57
- }
58
-
59
- Debug.Log("[Test2] Completed all 100 iterations");
60
- }
61
-
62
- /// <summary>
63
- /// Test 3: Multiple Async Operations
64
- /// Expected: All three delays should cancel together when Stop is clicked.
65
- /// </summary>
66
- [UnityTest]
67
- public async Task Test3_MultipleOperations_AllCancelTogether(CancellationToken ct)
68
- {
69
- Debug.Log("[Test3] Starting 3 parallel 5-second delays");
70
- Debug.Log("[Test3] Click STOP to cancel all operations together");
71
-
72
- var task1 = Task.Delay(5000, ct);
73
- var task2 = Task.Delay(5000, ct);
74
- var task3 = Task.Delay(5000, ct);
75
-
76
- await Task.WhenAll(task1, task2, task3);
77
-
78
- Debug.Log("[Test3] All operations completed successfully");
79
- }
80
-
81
- #if UNITASK_PRESENT
82
- /// <summary>
83
- /// Test 4: UniTask Cancellation
84
- /// Expected: UniTask should cancel immediately when Stop is clicked.
85
- /// NOTE: This test is designed for MANUAL testing. When run automatically, it WILL FAIL with Assert.Fail after 10 seconds.
86
- /// </summary>
87
- [UnityTest]
88
- public async UniTask Test4_UniTaskCancellation_ShouldFail(CancellationToken ct)
89
- {
90
- Debug.Log("[Test4] UniTask test started - will delay for 10 seconds");
91
- Debug.Log("[Test4] Click STOP button to test UniTask cancellation!");
92
-
93
- try
94
- {
95
- await UniTask.Delay(10000, cancellationToken: ct);
96
- Assert.Fail("[Test4] Should not reach here if cancelled");
97
- }
98
- catch (OperationCanceledException)
99
- {
100
- Debug.Log("[Test4] SUCCESS: UniTask cancellation was properly caught");
101
- throw; // Re-throw so MooseRunner handles it
102
- }
103
- }
104
- #endif
105
-
106
- /// <summary>
107
- /// Test 5: Backward Compatibility with Func&lt;bool&gt;
108
- /// Expected: Legacy pattern should still work - test should stop when Stop is clicked.
109
- /// </summary>
110
- [UnityTest]
111
- public async Task Test5_BackwardCompatibility_FuncBoolStillWorks(Func<bool> shouldStop)
112
- {
113
- Debug.Log("[Test5] Testing backward compatibility with Func<bool> pattern");
114
- Debug.Log("[Test5] Click STOP to test legacy cancellation mechanism");
115
-
116
- for (int i = 0; i < 10; i++)
117
- {
118
- if (shouldStop())
119
- {
120
- Debug.Log($"[Test5] SUCCESS: Stopped via Func<bool> at iteration {i}");
121
- return;
122
- }
123
- Debug.Log($"[Test5] Iteration {i}");
124
- await Task.Delay(1000);
125
- }
126
-
127
- Debug.Log("[Test5] Completed all 10 iterations");
128
- }
129
-
130
- /// <summary>
131
- /// Test 6: No Parameters (should run to completion)
132
- /// Expected: Test runs normally without cancellation support.
133
- /// </summary>
134
- [UnityTest]
135
- public async Task Test6_NoParameters_RunsNormally()
136
- {
137
- Debug.Log("[Test6] Test with no parameters - cannot be cancelled");
138
- await Task.Delay(2000);
139
- Debug.Log("[Test6] Test completed successfully");
140
- }
141
-
142
- /// <summary>
143
- /// Test 7: Long Running Cancellable Test
144
- /// Expected: Can be cancelled at any point during the 30 second runtime.
145
- /// </summary>
146
- [UnityTest]
147
- public async Task Test7_LongRunning_CancellableAnytime(CancellationToken ct)
148
- {
149
- Debug.Log("[Test7] Long-running test (30 seconds) - click STOP anytime");
150
-
151
- for (int i = 0; i < 30; i++)
152
- {
153
- Debug.Log($"[Test7] Second {i + 1}/30");
154
- await Task.Delay(1000, ct);
155
- }
156
-
157
- Debug.Log("[Test7] Completed full 30 seconds");
158
- }
159
-
160
- /// <summary>
161
- /// Test 8: Timeout Test
162
- /// Expected: Test should timeout after 2 seconds even though it tries to run for 10 seconds.
163
- /// NOTE: This requires timeout implementation in MooseRunner (not yet implemented).
164
- /// When run automatically, it WILL FAIL - either via timeout cancellation or Assert.Fail after 10 seconds.
165
- /// </summary>
166
- [UnityTest]
167
- [Timeout(2000)] // 2 second timeout
168
- public async Task Test8_Timeout_ShouldFail(CancellationToken ct)
169
- {
170
- Debug.Log("[Test8] Starting test with 2-second timeout, but will try to delay for 10 seconds");
171
- Debug.Log("[Test8] This test should automatically FAIL after 2 seconds");
172
-
173
- try
174
- {
175
- // Try to delay for 10 seconds, but timeout should cancel it after 2 seconds
176
- await Task.Delay(10000, ct);
177
- Assert.Fail("[Test8] Should not reach here - should timeout after 2 seconds");
178
- }
179
- catch (OperationCanceledException)
180
- {
181
- Debug.Log("[Test8] Task was cancelled - timeout triggered!");
182
- throw; // Re-throw so MooseRunner handles it
183
- }
184
- }
185
- }
186
- }
1
+ using System;
2
+ using System.Threading;
3
+ using System.Threading.Tasks;
4
+ using NUnit.Framework;
5
+ using UnityEngine;
6
+ using UnityEngine.TestTools;
7
+
8
+ #if UNITASK_PRESENT
9
+ using Cysharp.Threading.Tasks;
10
+ #endif
11
+
12
+ namespace MooseRunner.Internal.Tests
13
+ {
14
+ /// <summary>
15
+ /// Tests to validate CancellationToken implementation in MooseRunner.
16
+ /// These tests are designed for MANUAL testing - run them and click Stop button during execution.
17
+ /// </summary>
18
+ public class CancellationTokenTests
19
+ {
20
+ /// <summary>
21
+ /// Test 1: Basic Task Cancellation
22
+ /// Expected: When Stop is clicked, the test should cancel immediately and show "Test was cancelled" in console.
23
+ /// NOTE: This test is designed for MANUAL testing. When run automatically, it WILL FAIL with Assert.Fail after 10 seconds.
24
+ /// </summary>
25
+ [UnityTest]
26
+ public async Task Test1_BasicTaskCancellation_ShouldFail(CancellationToken ct)
27
+ {
28
+ Debug.Log("[Test1] Test started - will delay for 10 seconds");
29
+ Debug.Log("[Test1] Click STOP button within 1-2 seconds to test cancellation!");
30
+
31
+ try
32
+ {
33
+ await Task.Delay(10000, ct); // 10 second delay
34
+ Assert.Fail("[Test1] Should not reach here if cancelled");
35
+ }
36
+ catch (OperationCanceledException)
37
+ {
38
+ Debug.Log("[Test1] SUCCESS: Cancellation was properly caught by test method");
39
+ throw; // Re-throw so MooseRunner handles it
40
+ }
41
+ }
42
+
43
+ /// <summary>
44
+ /// Test 2: Cooperative Loop Cancellation
45
+ /// Expected: Loop should exit immediately when Stop is clicked, remaining iterations should not execute.
46
+ /// </summary>
47
+ [UnityTest]
48
+ public async Task Test2_CooperativeLoop_ShouldExitEarly(CancellationToken ct)
49
+ {
50
+ Debug.Log("[Test2] Starting 100 iterations - click STOP after ~5 iterations");
51
+
52
+ for (int i = 0; i < 100; i++)
53
+ {
54
+ Debug.Log($"[Test2] Iteration {i}");
55
+ await Task.Delay(100, ct);
56
+ ct.ThrowIfCancellationRequested(); // Explicit check
57
+ }
58
+
59
+ Debug.Log("[Test2] Completed all 100 iterations");
60
+ }
61
+
62
+ /// <summary>
63
+ /// Test 3: Multiple Async Operations
64
+ /// Expected: All three delays should cancel together when Stop is clicked.
65
+ /// </summary>
66
+ [UnityTest]
67
+ public async Task Test3_MultipleOperations_AllCancelTogether(CancellationToken ct)
68
+ {
69
+ Debug.Log("[Test3] Starting 3 parallel 5-second delays");
70
+ Debug.Log("[Test3] Click STOP to cancel all operations together");
71
+
72
+ var task1 = Task.Delay(5000, ct);
73
+ var task2 = Task.Delay(5000, ct);
74
+ var task3 = Task.Delay(5000, ct);
75
+
76
+ await Task.WhenAll(task1, task2, task3);
77
+
78
+ Debug.Log("[Test3] All operations completed successfully");
79
+ }
80
+
81
+ #if UNITASK_PRESENT
82
+ /// <summary>
83
+ /// Test 4: UniTask Cancellation
84
+ /// Expected: UniTask should cancel immediately when Stop is clicked.
85
+ /// NOTE: This test is designed for MANUAL testing. When run automatically, it WILL FAIL with Assert.Fail after 10 seconds.
86
+ /// </summary>
87
+ [UnityTest]
88
+ public async UniTask Test4_UniTaskCancellation_ShouldFail(CancellationToken ct)
89
+ {
90
+ Debug.Log("[Test4] UniTask test started - will delay for 10 seconds");
91
+ Debug.Log("[Test4] Click STOP button to test UniTask cancellation!");
92
+
93
+ try
94
+ {
95
+ await UniTask.Delay(10000, cancellationToken: ct);
96
+ Assert.Fail("[Test4] Should not reach here if cancelled");
97
+ }
98
+ catch (OperationCanceledException)
99
+ {
100
+ Debug.Log("[Test4] SUCCESS: UniTask cancellation was properly caught");
101
+ throw; // Re-throw so MooseRunner handles it
102
+ }
103
+ }
104
+ #endif
105
+
106
+ /// <summary>
107
+ /// Test 5: Backward Compatibility with Func&lt;bool&gt;
108
+ /// Expected: Legacy pattern should still work - test should stop when Stop is clicked.
109
+ /// </summary>
110
+ [UnityTest]
111
+ public async Task Test5_BackwardCompatibility_FuncBoolStillWorks(Func<bool> shouldStop)
112
+ {
113
+ Debug.Log("[Test5] Testing backward compatibility with Func<bool> pattern");
114
+ Debug.Log("[Test5] Click STOP to test legacy cancellation mechanism");
115
+
116
+ for (int i = 0; i < 10; i++)
117
+ {
118
+ if (shouldStop())
119
+ {
120
+ Debug.Log($"[Test5] SUCCESS: Stopped via Func<bool> at iteration {i}");
121
+ return;
122
+ }
123
+ Debug.Log($"[Test5] Iteration {i}");
124
+ await Task.Delay(1000);
125
+ }
126
+
127
+ Debug.Log("[Test5] Completed all 10 iterations");
128
+ }
129
+
130
+ /// <summary>
131
+ /// Test 6: No Parameters (should run to completion)
132
+ /// Expected: Test runs normally without cancellation support.
133
+ /// </summary>
134
+ [UnityTest]
135
+ public async Task Test6_NoParameters_RunsNormally()
136
+ {
137
+ Debug.Log("[Test6] Test with no parameters - cannot be cancelled");
138
+ await Task.Delay(2000);
139
+ Debug.Log("[Test6] Test completed successfully");
140
+ }
141
+
142
+ /// <summary>
143
+ /// Test 7: Long Running Cancellable Test
144
+ /// Expected: Can be cancelled at any point during the 30 second runtime.
145
+ /// </summary>
146
+ [UnityTest]
147
+ public async Task Test7_LongRunning_CancellableAnytime(CancellationToken ct)
148
+ {
149
+ Debug.Log("[Test7] Long-running test (30 seconds) - click STOP anytime");
150
+
151
+ for (int i = 0; i < 30; i++)
152
+ {
153
+ Debug.Log($"[Test7] Second {i + 1}/30");
154
+ await Task.Delay(1000, ct);
155
+ }
156
+
157
+ Debug.Log("[Test7] Completed full 30 seconds");
158
+ }
159
+
160
+ /// <summary>
161
+ /// Test 8: Timeout Test
162
+ /// Expected: Test should timeout after 2 seconds even though it tries to run for 10 seconds.
163
+ /// NOTE: This requires timeout implementation in MooseRunner (not yet implemented).
164
+ /// When run automatically, it WILL FAIL - either via timeout cancellation or Assert.Fail after 10 seconds.
165
+ /// </summary>
166
+ [UnityTest]
167
+ [Timeout(2000)] // 2 second timeout
168
+ public async Task Test8_Timeout_ShouldFail(CancellationToken ct)
169
+ {
170
+ Debug.Log("[Test8] Starting test with 2-second timeout, but will try to delay for 10 seconds");
171
+ Debug.Log("[Test8] This test should automatically FAIL after 2 seconds");
172
+
173
+ try
174
+ {
175
+ // Try to delay for 10 seconds, but timeout should cancel it after 2 seconds
176
+ await Task.Delay(10000, ct);
177
+ Assert.Fail("[Test8] Should not reach here - should timeout after 2 seconds");
178
+ }
179
+ catch (OperationCanceledException)
180
+ {
181
+ Debug.Log("[Test8] Task was cancelled - timeout triggered!");
182
+ throw; // Re-throw so MooseRunner handles it
183
+ }
184
+ }
185
+ }
186
+ }