com.valectric.mooserunner 2.1.4

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 (131) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/CLI~/mooserunnerCli.exe +0 -0
  3. package/CLI~/mooserunnerCliDaemon.exe +0 -0
  4. package/Editor/GUI/MooseRunnerFail.png +0 -0
  5. package/Editor/GUI/MooseRunnerFail.png.meta +140 -0
  6. package/Editor/GUI/MooseRunnerGreenLED.png +0 -0
  7. package/Editor/GUI/MooseRunnerGreenLED.png.meta +140 -0
  8. package/Editor/GUI/MooseRunnerLogoBannerSmall.png +0 -0
  9. package/Editor/GUI/MooseRunnerLogoBannerSmall.png.meta +140 -0
  10. package/Editor/GUI/MooseRunnerNotRun.png +0 -0
  11. package/Editor/GUI/MooseRunnerNotRun.png.meta +140 -0
  12. package/Editor/GUI/MooseRunnerPass.png +0 -0
  13. package/Editor/GUI/MooseRunnerPass.png.meta +140 -0
  14. package/Editor/GUI/MooseRunnerYellowLED.png +0 -0
  15. package/Editor/GUI/MooseRunnerYellowLED.png.meta +140 -0
  16. package/Editor/MooseRunner.Editor.asmdef +17 -0
  17. package/Editor/MooseRunner.Editor.asmdef.meta +7 -0
  18. package/Editor/MooseRunner.Internal.Editor.dll +0 -0
  19. package/Editor/MooseRunner.Internal.Editor.dll.meta +33 -0
  20. package/Editor/MooseRunner.SessionRecorder.dll +0 -0
  21. package/Editor/MooseRunner.SessionRecorder.dll.meta +33 -0
  22. package/Editor/MooseRunner.Worker.dll +0 -0
  23. package/Editor/MooseRunner.Worker.dll.meta +33 -0
  24. package/Editor/_WrapperStub.cs +3 -0
  25. package/Editor/_WrapperStub.cs.meta +11 -0
  26. package/LICENSE.md +28 -0
  27. package/README.md +347 -0
  28. package/Runtime/Helpers/DoNotDestroyOnTeardown/DoNotDestroyOnTeardown.cs +262 -0
  29. package/Runtime/Helpers/DoNotDestroyOnTeardown/DoNotDestroyOnTeardown.cs.meta +2 -0
  30. package/Runtime/Helpers/DoNotDestroyOnTeardown/MooseRunner.helper.asmdef +18 -0
  31. package/Runtime/Helpers/DoNotDestroyOnTeardown/MooseRunner.helper.asmdef.meta +7 -0
  32. package/Runtime/MooseRunner.Helpers.Runtime.dll +0 -0
  33. package/Runtime/MooseRunner.Helpers.Runtime.dll.meta +27 -0
  34. package/Runtime/MooseRunner.Internal.dll +0 -0
  35. package/Runtime/MooseRunner.Internal.dll.meta +27 -0
  36. package/Runtime/MooseRunner.Multiplaytest.Types.dll +0 -0
  37. package/Runtime/MooseRunner.Multiplaytest.Types.dll.meta +27 -0
  38. package/Runtime/MooseRunner.Runtime.asmdef +20 -0
  39. package/Runtime/MooseRunner.Runtime.asmdef.meta +7 -0
  40. package/Runtime/MooseRunner.SessionRecorder.Runtime.dll +0 -0
  41. package/Runtime/MooseRunner.SessionRecorder.Runtime.dll.meta +27 -0
  42. package/Runtime/MooseRunner.dll +0 -0
  43. package/Runtime/MooseRunner.dll.meta +27 -0
  44. package/Runtime/_WrapperStub.cs +3 -0
  45. package/Runtime/_WrapperStub.cs.meta +11 -0
  46. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/BatchCancellationTests.cs +37 -0
  47. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/BatchCancellationTests.cs.meta +2 -0
  48. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/CancellationTokenTests.cs +186 -0
  49. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/CancellationTokenTests.cs.meta +2 -0
  50. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/MooseRunner.Demo.CancellationTokens.Tests.asmdef +28 -0
  51. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/MooseRunner.Demo.CancellationTokens.Tests.asmdef.meta +7 -0
  52. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/SetupTeardownCancellationTests.cs +84 -0
  53. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/SetupTeardownCancellationTests.cs.meta +2 -0
  54. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/TESTING_INSTRUCTIONS.md +491 -0
  55. package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/TESTING_INSTRUCTIONS.md.meta +7 -0
  56. package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/ErrorHandelingTest.cs +177 -0
  57. package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/ErrorHandelingTest.cs.meta +11 -0
  58. package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/MooseRunner.Demo.ErrorHandling.Tests.asmdef +28 -0
  59. package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/MooseRunner.Demo.ErrorHandling.Tests.asmdef.meta +7 -0
  60. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogEntry.cs +51 -0
  61. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogEntry.cs.meta +11 -0
  62. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogFileParser.cs +70 -0
  63. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogFileParser.cs.meta +11 -0
  64. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunner.Demo.Flow.TestSupport.asmdef +22 -0
  65. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunner.Demo.Flow.TestSupport.asmdef.meta +7 -0
  66. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference.json +62 -0
  67. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference.json.meta +7 -0
  68. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_2.json +33 -0
  69. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_2.json.meta +7 -0
  70. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_No_UniTask.json +57 -0
  71. package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_No_UniTask.json.meta +7 -0
  72. package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MethodOrderAttributeTests.cs +62 -0
  73. package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MethodOrderAttributeTests.cs.meta +2 -0
  74. package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MooseRunner.Demo.OrderAttribute.asmdef +20 -0
  75. package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MooseRunner.Demo.OrderAttribute.asmdef.meta +7 -0
  76. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/CatAnimation.controller +276 -0
  77. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/CatAnimation.controller.meta +8 -0
  78. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Enemy.cs +101 -0
  79. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Enemy.cs.meta +11 -0
  80. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/FireComponent.cs +19 -0
  81. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/FireComponent.cs.meta +3 -0
  82. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model/Ghost_cat.fbx +0 -0
  83. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model/Ghost_cat.fbx.meta +547 -0
  84. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model.meta +8 -0
  85. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/MooseRunner.Demo.RealUseCase.asmdef +29 -0
  86. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/MooseRunner.Demo.RealUseCase.asmdef.meta +7 -0
  87. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseScene.unity +4758 -0
  88. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseScene.unity.meta +7 -0
  89. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseTest.cs +307 -0
  90. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseTest.cs.meta +3 -0
  91. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources/Ghost_cat.prefab +157 -0
  92. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources/Ghost_cat.prefab.meta +7 -0
  93. package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources.meta +8 -0
  94. package/Samples~/Demos/MooseRunner.Demo.Support/MessageDisplayManager.cs +291 -0
  95. package/Samples~/Demos/MooseRunner.Demo.Support/MessageDisplayManager.cs.meta +11 -0
  96. package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunner.Demo.Support.asmdef +19 -0
  97. package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunner.Demo.Support.asmdef.meta +7 -0
  98. package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestBase1.cs +71 -0
  99. package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestBase1.cs.meta +11 -0
  100. package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass1.cs +301 -0
  101. package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass1.cs.meta +11 -0
  102. package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass2.cs +69 -0
  103. package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass2.cs.meta +11 -0
  104. package/Samples~/Demos/MooseRunner.Demo.Tests/ExplicitAttributeTests.cs +36 -0
  105. package/Samples~/Demos/MooseRunner.Demo.Tests/ExplicitAttributeTests.cs.meta +2 -0
  106. package/Samples~/Demos/MooseRunner.Demo.Tests/HumanReviewModeDemo.cs +99 -0
  107. package/Samples~/Demos/MooseRunner.Demo.Tests/HumanReviewModeDemo.cs.meta +2 -0
  108. package/Samples~/Demos/MooseRunner.Demo.Tests/InstanceHandlingVerificationTest.cs +99 -0
  109. package/Samples~/Demos/MooseRunner.Demo.Tests/InstanceHandlingVerificationTest.cs.meta +2 -0
  110. package/Samples~/Demos/MooseRunner.Demo.Tests/MooseRunner.Demo.Tests.asmdef +23 -0
  111. package/Samples~/Demos/MooseRunner.Demo.Tests/MooseRunner.Demo.Tests.asmdef.meta +7 -0
  112. package/Samples~/Demos/MooseRunner.Demo.Tests/PauseTestExecutionDemo.cs +74 -0
  113. package/Samples~/Demos/MooseRunner.Demo.Tests/PauseTestExecutionDemo.cs.meta +2 -0
  114. package/Samples~/Demos/TestResources/OneCamera/Materials/Background.mat +137 -0
  115. package/Samples~/Demos/TestResources/OneCamera/Materials/Background.mat.meta +8 -0
  116. package/Samples~/Demos/TestResources/OneCamera/Materials/Background.png +0 -0
  117. package/Samples~/Demos/TestResources/OneCamera/Materials/Background.png.meta +127 -0
  118. package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.mat +71 -0
  119. package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.mat.meta +8 -0
  120. package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.png +0 -0
  121. package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.png.meta +127 -0
  122. package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.shadergraph +1910 -0
  123. package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.shadergraph.meta +10 -0
  124. package/Samples~/Demos/TestResources/OneCamera/Materials/GridNormal.png +0 -0
  125. package/Samples~/Demos/TestResources/OneCamera/Materials/GridNormal.png.meta +127 -0
  126. package/Samples~/Demos/TestResources/OneCamera/Materials.meta +8 -0
  127. package/Samples~/Demos/TestResources/OneCamera/OneCameraScene.unity +598 -0
  128. package/Samples~/Demos/TestResources/OneCamera/OneCameraScene.unity.meta +7 -0
  129. package/Samples~/Demos/TestResources/OneCamera.meta +8 -0
  130. package/Third Party Notices.md +37 -0
  131. package/package.json +38 -0
@@ -0,0 +1,301 @@
1
+ using System;
2
+ using System.Collections;
3
+ using System.IO;
4
+ using System.Reflection;
5
+ using System.Threading.Tasks;
6
+ using NUnit.Framework;
7
+ using UnityEngine;
8
+ using UnityEngine.TestTools;
9
+ using MooseRunner.Multiplaytest;
10
+
11
+ using System.Linq;
12
+ using System.Runtime.CompilerServices;
13
+
14
+ using System.Xml;
15
+ using UnityEngine.SceneManagement;
16
+
17
+ namespace MooseRunner.Internal.Tests
18
+ {
19
+ public class DummyTestClass1 : DummyTestBase1
20
+ {
21
+ /// <summary>
22
+ /// Sets up the test environment before any test is executed.
23
+ /// Ensures that the "OneCameraScene" is created with a camera.
24
+ /// If the scene does not exist, it creates a new scene with a camera,
25
+ /// unloads all other scenes, and makes the new scene active.
26
+ /// </summary>
27
+ /// <returns>An enumerator for the asynchronous setup process.</returns>
28
+
29
+ [OneTimeSetUp]
30
+ public new async Task SetUpOnce()
31
+ {
32
+ await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
33
+ }
34
+
35
+ // Regular setup, called before each individual test
36
+ [SetUp]
37
+ public IEnumerator SetUp()
38
+ {
39
+ Debug.Log("DummyTestClass1 SetUp: Called before each test.");
40
+
41
+ // Pause for 500ms
42
+ yield return new WaitForSeconds(0.5f); // 500ms pause
43
+ }
44
+
45
+ // Dummy test that runs synchronously
46
+ [Test]
47
+ public new void SyncTest()
48
+ {
49
+ Debug.Log("DummyTestClass1 SyncTest: This is a synchronous test.");
50
+ ExtractMooseRunnerMethodsWithCommentsToFile(); //Just to help when generating base draft using chatGPT.
51
+ MessageDisplayManager.Instance.ShowMessage("DummyTestClass1 SyncTest");
52
+ Assert.IsTrue(true); // Dummy assertion
53
+ }
54
+
55
+ // Dummy test that runs asynchronously (PlayMode)
56
+ [UnityTest]
57
+ public IEnumerator CoroutineTest()
58
+ {
59
+ Debug.Log("DummyTestClass1 CoroutineTest: This is an coroutine test.");
60
+ for (int i = 0; i < 20; i++)
61
+ {
62
+ MessageDisplayManager.Instance.ShowMessage("DummyTestClass1 CoroutineTest wait for " + (20 - i).ToString());
63
+ yield return new WaitForSeconds(1); // Simulate some asynchronous behavior
64
+ }
65
+ MessageDisplayManager.Instance.ShowMessage("DummyTestClass1 CoroutineTest wait for 0");
66
+ Assert.IsTrue(true); // Dummy assertion
67
+ }
68
+
69
+ // Regular teardown, called after each individual test
70
+ [TearDown]
71
+ public void TearDown()
72
+ {
73
+ Debug.Log("DummyTestClass1 TearDown: Called after each test.");
74
+ }
75
+
76
+ // One-time teardown, called once after all tests in this class
77
+ [OneTimeTearDown]
78
+ public void OneTimeTearDown()
79
+ {
80
+ Debug.Log("DummyTestClass1 OneTimeTearDown: Called once after all tests.");
81
+ }
82
+
83
+ #region REAL_TEST_METHODS
84
+ // Real test methods go here
85
+
86
+ private const int _simulatedRuntimeInGameSeconds = 10; // Simulated duration in game seconds
87
+ private int _fixedUpdateCount;
88
+ private float _totalRealTimeElapsed;
89
+ private float _maxFixedUpdateTime;
90
+
91
+ /// <summary>
92
+ /// Unit test that runs a coroutine to measure real-world time and count FixedUpdate calls,
93
+ /// waiting for a duration affected by Time.timeScale and ensuring no missed frames.
94
+ /// </summary>
95
+ /// <returns>IEnumerator for the Unity test runner.</returns>
96
+ [UnityTest]
97
+ public IEnumerator MeasureFixedUpdatePerformance()
98
+ {
99
+ MessageDisplayManager.Instance.ShowMessage("MeasureFixedUpdatePerformance start");
100
+ // Initialize variables
101
+ _fixedUpdateCount = 0;
102
+ _totalRealTimeElapsed = 0.0f;
103
+ _maxFixedUpdateTime = 0.0f;
104
+
105
+ // Create a GameObject to attach FixedUpdate counting behavior
106
+ var testObject = new GameObject("TestObject");
107
+ testObject.AddComponent<FixedUpdateCounter>().Initialize(this);
108
+
109
+ // Record the starting real-world time
110
+ float startTime = Time.realtimeSinceStartup;
111
+
112
+ Debug.Log("Timescale: " + Time.timeScale + " SimulatedRuntimeInGameSeconds: " + _simulatedRuntimeInGameSeconds);
113
+
114
+ // Wait for the specified duration in game time (affected by Time.timeScale)
115
+ for (int i = 0; i < _simulatedRuntimeInGameSeconds; i++)
116
+ {
117
+ MessageDisplayManager.Instance.ShowMessage("MeasureFixedUpdatePerformance wait for " + (_simulatedRuntimeInGameSeconds - i).ToString());
118
+ yield return new WaitForSeconds(1);
119
+ }
120
+ MessageDisplayManager.Instance.ShowMessage("MeasureFixedUpdatePerformance wait for 0");
121
+
122
+ Debug.Log("Wait done");
123
+
124
+ // Calculate the total real-world time elapsed
125
+ _totalRealTimeElapsed = Time.realtimeSinceStartup - startTime;
126
+
127
+ // Calculate the expected number of FixedUpdate calls
128
+ int expectedFixedUpdates = Mathf.CeilToInt(_simulatedRuntimeInGameSeconds / 0.02f); // Simulated time divided by 0.02s per FixedUpdate
129
+
130
+ // Clean up
131
+ GameObject.Destroy(testObject);
132
+
133
+ // Assertion 1: Check if the number of FixedUpdate calls is within an acceptable range
134
+ Assert.IsTrue(
135
+ Mathf.Abs(_fixedUpdateCount - expectedFixedUpdates) <= 60,
136
+ $"Expected approximately {expectedFixedUpdates} FixedUpdate calls, but got {_fixedUpdateCount}."
137
+ );
138
+
139
+ // Assertion 2: Check if the total real-world time is within the expected scaled-down time range
140
+ float expectedRealTime = _simulatedRuntimeInGameSeconds / Time.timeScale;
141
+ Assert.IsTrue(
142
+ Mathf.Abs(_totalRealTimeElapsed - expectedRealTime) < 0.8f, // Allow a small margin of error
143
+ $"The real-world time elapsed ({_totalRealTimeElapsed:F2} seconds) should be close to the expected scaled time ({expectedRealTime:F2} seconds)."
144
+ );
145
+
146
+
147
+ //Assertion 3: Check if the max delta time is bigger that the default value + 30% to see in any frame is missed.
148
+ Assert.IsTrue(
149
+ _maxFixedUpdateTime <= 0.02f * 1.3f,
150
+ $"The maximum FixedUpdate delta time ({_maxFixedUpdateTime:F4} seconds) should not exceed 30% more than the default FixedUpdate time (0.02 seconds)."
151
+ );
152
+
153
+
154
+ Debug.Log("maxFixedUpdateTime: " + _maxFixedUpdateTime);
155
+
156
+
157
+ }
158
+
159
+
160
+ public static void ExtractMooseRunnerMethodsWithCommentsToFile()
161
+ {
162
+ string outputFilePath = "FilteredMooseRunnerMethodsWithComments.txt";
163
+ Assembly[] allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
164
+
165
+ using (var writer = new StreamWriter(outputFilePath, false))
166
+ {
167
+ foreach (Assembly asm in allAssemblies)
168
+ {
169
+ string asmName = asm.GetName().Name;
170
+ if (!asmName.StartsWith("MooseRunner", StringComparison.OrdinalIgnoreCase))
171
+ {
172
+ continue;
173
+ }
174
+
175
+ writer.WriteLine($"Assembly: {asmName}");
176
+
177
+ Type[] allTypes;
178
+ try
179
+ {
180
+ allTypes = asm.GetTypes();
181
+ }
182
+ catch (ReflectionTypeLoadException e)
183
+ {
184
+ allTypes = e.Types.Where(t => t != null).ToArray();
185
+ }
186
+
187
+ foreach (Type t in allTypes)
188
+ {
189
+ if (t.IsDefined(typeof(CompilerGeneratedAttribute), true) || t.FullName.Contains("<") || t.FullName.Contains("Private"))
190
+ {
191
+ continue; // Skip compiler-generated and private implementation classes
192
+ }
193
+
194
+ writer.WriteLine($"\tClass: {t.FullName}");
195
+ string classComment = GetXmlDocumentationForType(t);
196
+ if (!string.IsNullOrWhiteSpace(classComment))
197
+ {
198
+ writer.WriteLine($"\t\tComment: {classComment.Trim()}");
199
+ }
200
+
201
+ var methods = t.GetMethods(
202
+ BindingFlags.Public | BindingFlags.NonPublic |
203
+ BindingFlags.Instance | BindingFlags.Static);
204
+
205
+ foreach (MethodInfo m in methods)
206
+ {
207
+ if (m.IsDefined(typeof(CompilerGeneratedAttribute), true) || IsSystemMethod(m))
208
+ {
209
+ continue; // Skip compiler-generated and system methods
210
+ }
211
+
212
+ writer.WriteLine($"\t\tMethod: {m.Name}");
213
+ string methodComment = GetXmlDocumentationForMethod(m);
214
+ if (!string.IsNullOrWhiteSpace(methodComment))
215
+ {
216
+ writer.WriteLine($"\t\t\tComment: {methodComment.Trim()}");
217
+ }
218
+ }
219
+ }
220
+
221
+ writer.WriteLine();
222
+ }
223
+ }
224
+
225
+ Debug.Log($"Filtered MooseRunner methods with comments have been written to: {outputFilePath}");
226
+ }
227
+
228
+ /// <summary>
229
+ /// Determines if a method is system-generated or framework-related.
230
+ /// </summary>
231
+ private static bool IsSystemMethod(MethodInfo method)
232
+ {
233
+ var systemNamespaces = new[] { "System", "UnityEngine", "Microsoft", "Mono" };
234
+ return systemNamespaces.Any(ns => method.DeclaringType?.Namespace?.StartsWith(ns) == true) ||
235
+ method.Name.StartsWith("get_") || method.Name.StartsWith("set_") || method.Name.StartsWith("add_") ||
236
+ method.Name.StartsWith("remove_") || method.Name.StartsWith("op_");
237
+ }
238
+
239
+ /// <summary>
240
+ /// Retrieves XML documentation for a class (type).
241
+ /// </summary>
242
+ private static string GetXmlDocumentationForType(Type type)
243
+ {
244
+ return type.GetCustomAttributes<DocumentationAttribute>()?.FirstOrDefault()?.Documentation ?? string.Empty;
245
+ }
246
+
247
+ /// <summary>
248
+ /// Retrieves XML documentation for a method.
249
+ /// </summary>
250
+ private static string GetXmlDocumentationForMethod(MethodInfo method)
251
+ {
252
+ return method.GetCustomAttributes<DocumentationAttribute>()?.FirstOrDefault()?.Documentation ?? string.Empty;
253
+ }
254
+
255
+ /// <summary>
256
+ /// Example attribute for holding XML documentation (simulates IntelliSense-like comments).
257
+ /// </summary>
258
+ [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
259
+ sealed class DocumentationAttribute : Attribute
260
+ {
261
+ public string Documentation { get; }
262
+ public DocumentationAttribute(string documentation)
263
+ {
264
+ Documentation = documentation;
265
+ }
266
+ }
267
+
268
+
269
+
270
+
271
+
272
+
273
+ /// <summary>
274
+ /// Helper class to count FixedUpdate calls and simulate real-world time.
275
+ /// </summary>
276
+ private class FixedUpdateCounter : MonoBehaviour
277
+ {
278
+ private DummyTestClass1 parent;
279
+
280
+ public void Initialize(DummyTestClass1 parent)
281
+ {
282
+ this.parent = parent;
283
+ }
284
+
285
+ void FixedUpdate()
286
+ {
287
+ if (parent == null) {
288
+ Destroy(gameObject); //If disconected destroy itself.
289
+ return;
290
+ }
291
+ parent._fixedUpdateCount++;
292
+ if (Time.deltaTime > parent._maxFixedUpdateTime)
293
+ {
294
+ parent._maxFixedUpdateTime = Time.deltaTime;
295
+ }
296
+
297
+ }
298
+ }
299
+ #endregion REAL_TEST_METHODS
300
+ }
301
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: dbd74b7835b241743a3b7774a9895d5a
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,69 @@
1
+ using System.Collections;
2
+ using System.Threading.Tasks;
3
+ using NUnit.Framework;
4
+ using UnityEngine;
5
+ using UnityEngine.SceneManagement;
6
+ using UnityEngine.TestTools;
7
+ using MooseRunner.Multiplaytest;
8
+
9
+
10
+ namespace MooseRunner.Internal.Tests
11
+ {
12
+ public class DummyTestClass2
13
+ {
14
+ /// <summary>
15
+ /// Sets up the test environment before any test is executed.
16
+ /// Ensures that the "OneCameraScene" is created with a camera.
17
+ /// If the scene does not exist, it creates a new scene with a camera,
18
+ /// unloads all other scenes, and makes the new scene active.
19
+ /// </summary>
20
+ /// <returns>An enumerator for the asynchronous setup process.</returns>
21
+
22
+ [OneTimeSetUp]
23
+ public async Task SetUpOnce()
24
+ {
25
+ await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
26
+ }
27
+
28
+ // Regular setup, called before each individual test
29
+ [SetUp]
30
+ public void SetUp()
31
+ {
32
+ Debug.Log("DummyTestClass2 SetUp: Called before each test.");
33
+ }
34
+
35
+ // Dummy test that runs synchronously
36
+ [Test]
37
+ public void SyncTest()
38
+ {
39
+ Debug.Log("DummyTestClass2 SyncTest: This is a synchronous test.");
40
+ MessageDisplayManager.Instance.ShowMessage("DummyTestClass2 SyncTest");
41
+ Assert.IsTrue(true); // Dummy assertion
42
+ }
43
+
44
+ // Dummy test that runs asynchronously (PlayMode)
45
+ [UnityTest]
46
+ public IEnumerator CoroutineTest()
47
+ {
48
+ Debug.Log("DummyTestClass2 CoroutineTest: This is an coroutine test.");
49
+ MessageDisplayManager.Instance.ShowMessage("DummyTestClass2 Coroutine wait for 1");
50
+ yield return new WaitForSeconds(1); // Simulate some asynchronous behavior
51
+ MessageDisplayManager.Instance.ShowMessage("DummyTestClass2 Coroutine wait for 0");
52
+ Assert.IsTrue(true); // Dummy assertion
53
+ }
54
+
55
+ // Regular teardown, called after each individual test
56
+ [TearDown]
57
+ public void TearDown()
58
+ {
59
+ Debug.Log("DummyTestClass2 TearDown: Called after each test.");
60
+ }
61
+
62
+ // One-time teardown, called once after all tests in this class
63
+ [OneTimeTearDown]
64
+ public void OneTimeTearDown()
65
+ {
66
+ Debug.Log("DummyTestClass2 OneTimeTearDown: Called once after all tests.");
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 69aad0a9050743b47af599d040071fc1
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,36 @@
1
+ using NUnit.Framework;
2
+ using UnityEngine;
3
+
4
+ namespace MooseRunner.Internal.Tests
5
+ {
6
+ /// <summary>
7
+ /// Tests to verify [Explicit] attribute handling in MooseRunner.
8
+ /// - Normal tests should run in batch mode (class/assembly/root selection)
9
+ /// - [Explicit] tests should only run when directly selected
10
+ /// </summary>
11
+ [TestFixture]
12
+ public class ExplicitAttributeTests
13
+ {
14
+ [Test]
15
+ public void NormalTest_ShouldAlwaysRun()
16
+ {
17
+ Debug.Log("NormalTest_ShouldAlwaysRun: This test runs in all scenarios.");
18
+ Assert.Pass("Normal test passed");
19
+ }
20
+
21
+ [Test]
22
+ [Explicit("This test should only run when explicitly selected")]
23
+ public void ExplicitTest_ShouldOnlyRunWhenDirectlySelected()
24
+ {
25
+ Debug.Log("ExplicitTest_ShouldOnlyRunWhenDirectlySelected: This test should only run when directly selected.");
26
+ Assert.Pass("Explicit test passed - this means it was directly selected");
27
+ }
28
+
29
+ [Test]
30
+ public void AnotherNormalTest_ShouldAlwaysRun()
31
+ {
32
+ Debug.Log("AnotherNormalTest_ShouldAlwaysRun: This is another normal test.");
33
+ Assert.Pass("Another normal test passed");
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: a7375cda4fc58724f88a1b5b24b64037
@@ -0,0 +1,99 @@
1
+ using System.Threading;
2
+ using Cysharp.Threading.Tasks;
3
+ using MooseRunner.Multiplaytest;
4
+ using MooseRunner.helper;
5
+ using NUnit.Framework;
6
+ using UnityEngine;
7
+
8
+ namespace MooseRunner.Internal.Tests
9
+ {
10
+ /// <summary>
11
+ /// Demonstrates the Human Review Mode feature.
12
+ /// When Human Review Mode is enabled in MooseRunner settings,
13
+ /// this test adds delays so humans can observe state transitions.
14
+ /// </summary>
15
+ public class HumanReviewModeDemo
16
+ {
17
+ private GameObject _cube;
18
+
19
+ [SetUp]
20
+ public void SetUp()
21
+ {
22
+ DoNotDestroyOnTeardown.CleanSceneImmediate();
23
+ }
24
+
25
+ /// <summary>
26
+ /// Demonstrates Human Review Mode by moving a cube through different positions.
27
+ /// When Human Review Mode is ON: pauses 1 second between each position.
28
+ /// When Human Review Mode is OFF: runs at full speed.
29
+ /// </summary>
30
+ [Test]
31
+ public async UniTask CubeMovesWithHumanReviewDelays(CancellationToken ct)
32
+ {
33
+ // Arrange
34
+ bool humanReviewMode = MooseRunnerFacade.Instance.GetHumanReviewMode();
35
+ Debug.Log($"Human Review Mode: {(humanReviewMode ? "ON - will pause between steps" : "OFF - running at full speed")}");
36
+
37
+ _cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
38
+ _cube.name = "DemoCube";
39
+ _cube.transform.position = Vector3.zero;
40
+
41
+ // Act & Assert - Move through positions
42
+ Vector3[] positions = new[]
43
+ {
44
+ new Vector3(0, 0, 0),
45
+ new Vector3(2, 0, 0),
46
+ new Vector3(2, 2, 0),
47
+ new Vector3(0, 2, 0),
48
+ new Vector3(0, 0, 0)
49
+ };
50
+
51
+ for (int i = 0; i < positions.Length; i++)
52
+ {
53
+ _cube.transform.position = positions[i];
54
+ Debug.Log($"Step {i + 1}/{positions.Length}: Cube at {positions[i]}");
55
+
56
+ // If Human Review Mode is enabled, pause for observation
57
+ if (humanReviewMode)
58
+ {
59
+ await UniTask.Delay(1000, cancellationToken: ct); // 1 second pause
60
+ }
61
+ else
62
+ {
63
+ await UniTask.Yield(ct); // Just yield to next frame
64
+ }
65
+ }
66
+
67
+ Assert.AreEqual(Vector3.zero, _cube.transform.position);
68
+ Debug.Log("Test complete!");
69
+ }
70
+
71
+ /// <summary>
72
+ /// Simple test to verify the API works correctly.
73
+ /// </summary>
74
+ [Test]
75
+ public void CanReadAndSetHumanReviewMode()
76
+ {
77
+ // Get initial state
78
+ bool initialState = MooseRunnerFacade.Instance.GetHumanReviewMode();
79
+ Debug.Log($"Initial Human Review Mode: {initialState}");
80
+
81
+ // Toggle it
82
+ MooseRunnerFacade.Instance.SetHumanReviewMode(!initialState);
83
+ bool toggledState = MooseRunnerFacade.Instance.GetHumanReviewMode();
84
+ Assert.AreEqual(!initialState, toggledState, "SetHumanReviewMode should change the state");
85
+
86
+ // Restore original state
87
+ MooseRunnerFacade.Instance.SetHumanReviewMode(initialState);
88
+ Assert.AreEqual(initialState, MooseRunnerFacade.Instance.GetHumanReviewMode(), "Should restore to initial state");
89
+
90
+ Debug.Log("API test passed!");
91
+ }
92
+
93
+ [TearDown]
94
+ public async UniTask TearDown(CancellationToken ct)
95
+ {
96
+ await DoNotDestroyOnTeardown.CleanSceneSafeUsingUpdateAsync(false, ct);
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: d9c4bd004b2df0c4f8d8a6094b3aaf5a
@@ -0,0 +1,99 @@
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using NUnit.Framework;
5
+ using UnityEngine;
6
+ using UnityEngine.TestTools;
7
+
8
+ namespace MooseRunner.Internal.Tests
9
+ {
10
+ /// <summary>
11
+ /// Test class to verify that OneTimeSetUp and OneTimeTearDown methods get fresh instances
12
+ /// while regular test methods (SetUp/Test/TearDown) share the same instance within a test cycle.
13
+ /// Uses _instanceId with default value 99 to track instance persistence.
14
+ /// </summary>
15
+ public class InstanceHandlingVerificationTest
16
+ {
17
+
18
+ // Instance identifier - defaults to 99, each method should verify the expected previous value
19
+ private int _instanceId = 99;
20
+
21
+ // Constructor called when creating a new instance
22
+ public InstanceHandlingVerificationTest()
23
+ {
24
+ Debug.Log($"Constructor called, _instanceId set to {_instanceId}");
25
+ }
26
+
27
+ [OneTimeSetUp]
28
+ public void OneTimeSetUpMethod()
29
+ {
30
+ // OneTimeSetUp should get a fresh instance, so _instanceId should be 99 (default)
31
+ Assert.AreEqual(99, _instanceId, "OneTimeSetUp should start with default _instanceId = 99 (fresh instance)");
32
+
33
+ _instanceId = 100; // Set to new value
34
+ Debug.Log($"OneTimeSetUp: verified _instanceId was 99, changed to {_instanceId}");
35
+ }
36
+
37
+ [SetUp]
38
+ public void SetUpMethod()
39
+ {
40
+ // SetUp should get a fresh instance for each test, so _instanceId should be 99 (default)
41
+ Assert.AreEqual(99, _instanceId, "SetUp should start with default _instanceId = 99 (fresh instance for each test)");
42
+
43
+ _instanceId = 200; // Set to new value for test methods to verify
44
+ Debug.Log($"SetUp: verified _instanceId was 99, changed to {_instanceId}");
45
+ }
46
+
47
+ [Test]
48
+ public void FirstTest()
49
+ {
50
+ // Test should use same instance as SetUp, so _instanceId should be 200
51
+ Assert.AreEqual(200, _instanceId, "FirstTest should see _instanceId = 200 from SetUp (same instance)");
52
+
53
+ _instanceId = 300; // Change for TearDown to verify
54
+ Debug.Log($"FirstTest: verified _instanceId was 200, changed to {_instanceId}");
55
+ }
56
+
57
+ [Test]
58
+ public void SecondTest()
59
+ {
60
+ // Test should use same instance as SetUp, so _instanceId should be 200
61
+ Assert.AreEqual(200, _instanceId, "SecondTest should see _instanceId = 200 from SetUp (same instance)");
62
+
63
+ _instanceId = 400; // Change for TearDown to verify
64
+ Debug.Log($"SecondTest: verified _instanceId was 200, changed to {_instanceId}");
65
+ }
66
+
67
+ [UnityTest]
68
+ public IEnumerator CoroutineTest()
69
+ {
70
+ // Test should use same instance as SetUp, so _instanceId should be 200
71
+ Assert.AreEqual(200, _instanceId, "CoroutineTest should see _instanceId = 200 from SetUp (same instance)");
72
+
73
+ _instanceId = 500; // Change for TearDown to verify
74
+ Debug.Log($"CoroutineTest: verified _instanceId was 200, changed to {_instanceId}");
75
+ yield return new WaitForSeconds(0.1f);
76
+ }
77
+
78
+ [TearDown]
79
+ public void TearDownMethod()
80
+ {
81
+ // TearDown should use same instance as the test method, so _instanceId should be what the test set
82
+ // (300 for FirstTest, 400 for SecondTest, 500 for CoroutineTest)
83
+ Assert.IsTrue(_instanceId == 300 || _instanceId == 400 || _instanceId == 500,
84
+ $"TearDown should see _instanceId from test method (300, 400, or 500), but got {_instanceId}");
85
+
86
+ Debug.Log($"TearDown: verified _instanceId was {_instanceId} (from test method - same instance)");
87
+ }
88
+
89
+ [OneTimeTearDown]
90
+ public void OneTimeTearDownMethod()
91
+ {
92
+ // OneTimeTearDown should get a fresh instance, so _instanceId should be 99 (default)
93
+ Assert.AreEqual(99, _instanceId, "OneTimeTearDown should start with default _instanceId = 99 (fresh instance)");
94
+
95
+ Debug.Log($"OneTimeTearDown: verified _instanceId was 99 (fresh instance)");
96
+
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 18936c5f5d120004196c6ebb90918936
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "MooseRunner.Demo.Tests",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "UnityEngine.TestRunner",
6
+ "MooseRunner.Demo.Support",
7
+ "UniTask",
8
+ "MooseRunner.helper",
9
+ "MooseRunner.Runtime"
10
+ ],
11
+ "includePlatforms": [],
12
+ "excludePlatforms": [],
13
+ "allowUnsafeCode": false,
14
+ "precompiledReferences": [
15
+ "nunit.framework.dll"
16
+ ],
17
+ "autoReferenced": false,
18
+ "defineConstraints": [
19
+ "UNITY_INCLUDE_TESTS"
20
+ ],
21
+ "versionDefines": [],
22
+ "noEngineReferences": false
23
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 28c2a1491b1c6ad4d841540d822ae61c
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant: