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,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 828da812fa72793438ab286d6ad78341
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,307 @@
1
+ using System;
2
+ using UnityEngine;
3
+ using NUnit.Framework;
4
+ using System.Collections;
5
+ using Object = UnityEngine.Object;
6
+ using MooseRunner.Multiplaytest;
7
+ using MooseRunner.helper;
8
+ using System.Threading.Tasks;
9
+
10
+ namespace MooseRunner.Internal.Tests
11
+ {
12
+ /// <summary>
13
+ /// A test class for managing and executing Unity scene-based tests.
14
+ /// </summary>
15
+ [Category("Integration")]
16
+ public class RealUseCaseTest
17
+ {
18
+
19
+ /// <summary>
20
+ /// Sets up the test environment before any test is executed.
21
+ /// Ensures that the test scene is loaded and all other scenes are unloaded.
22
+ /// </summary>
23
+ /// <returns>An enumerator for the asynchronous setup process.</returns>
24
+ [OneTimeSetUp]
25
+ public async Task SetUpOnce()
26
+ {
27
+ await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("RealUseCaseScene");
28
+ }
29
+
30
+
31
+ /// <summary>
32
+ /// Sets up the test environment before each test is executed.
33
+ /// Cleans the scene using DoNotDestroyOnTeardown (preserves objects with that component).
34
+ /// </summary>
35
+ [SetUp]
36
+ public void SetUp()
37
+ {
38
+ Debug.Log("DemoTest SetUp: Called before each test.");
39
+ DoNotDestroyOnTeardown.CleanSceneImmediate();
40
+ }
41
+
42
+ [Test]
43
+ public async Task SpawnAndMoveForward(Func<bool> shouldStop)
44
+ {
45
+ // Load the "Ghost_Cat" prefab from the Resources folder
46
+ GameObject ghostCatPrefab = Resources.Load<GameObject>("Ghost_Cat");
47
+ Assert.IsNotNull(ghostCatPrefab, "The Ghost_Cat prefab could not be found in the Resources folder.");
48
+
49
+ // Spawn the "Ghost_Cat" prefab into the scene
50
+ GameObject ghostCatInstance = Object.Instantiate(ghostCatPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity);
51
+ Assert.IsNotNull(ghostCatInstance, "Failed to instantiate the Ghost_Cat prefab.");
52
+
53
+ // Wait for the next frame to allow Animator initialization
54
+ await Task.Yield();
55
+
56
+ // Get the Enemy component
57
+ Enemy enemyComponent = ghostCatInstance.transform.GetComponent<Enemy>();
58
+ Assert.IsNotNull(enemyComponent, "The Ghost_Cat instance does not have an Enemy component.");
59
+
60
+ // Get the Animator component
61
+ Animator animator = ghostCatInstance.GetComponent<Animator>();
62
+ Assert.IsNotNull(animator, "The Ghost_Cat instance does not have an Animator component.");
63
+
64
+ // Enable the moveForward property to make the enemy move
65
+ enemyComponent.moveForward = true;
66
+
67
+ // Wait for the next frame to ensure movement starts
68
+ await Task.Yield();
69
+
70
+ // Record initial position
71
+ Vector3 initialPosition = ghostCatInstance.transform.position;
72
+
73
+ // Wait for 2 seconds respective to Unity's time scale
74
+ await WaitForSecondsUnity(2f);
75
+
76
+ // Check Animator's "speed" parameter
77
+ float animatorSpeed = animator.GetFloat("Speed");
78
+ Assert.AreEqual(1f, animatorSpeed, "Animator's 'speed' parameter was not set to 1.");
79
+
80
+ // Record the new position
81
+ Vector3 newPosition = ghostCatInstance.transform.position;
82
+
83
+ // Assert that the enemy moved forward along the reverse z-axis
84
+ Assert.Greater(newPosition.z - 0.8, initialPosition.z, "The Ghost_Cat did not move forward as expected.");
85
+
86
+ // Stop the character
87
+ enemyComponent.moveForward = false;
88
+ }
89
+
90
+ /// <summary>
91
+ /// Waits for the specified time in seconds, scaled by Unity's time scale.
92
+ /// </summary>
93
+ /// <param name="seconds">The duration to wait, in Unity-time-scaled seconds.</param>
94
+ private async Task WaitForSecondsUnity(float seconds)
95
+ {
96
+ float elapsedTime = 0f;
97
+
98
+ while (elapsedTime < seconds)
99
+ {
100
+ // Break down execution and yield to the next frame
101
+ await Task.Yield();
102
+ // Increment elapsed time based on scaled delta time
103
+ elapsedTime += Time.deltaTime;
104
+ }
105
+ }
106
+
107
+ /// <summary>
108
+ /// Tests that the "Ghost_Cat" prefab detects and reacts correctly when colliding with a wall.
109
+ /// </summary>
110
+ [Test]
111
+ public async Task TestCollisionWithWall()
112
+ {
113
+ // Load the "Ghost_Cat" prefab from the Resources folder
114
+ GameObject ghostCatPrefab = Resources.Load<GameObject>("Ghost_Cat");
115
+ Assert.IsNotNull(ghostCatPrefab, "The Ghost_Cat prefab could not be found in the Resources folder.");
116
+
117
+ // Spawn the "Ghost_Cat" prefab into the scene
118
+ GameObject ghostCatInstance =
119
+ Object.Instantiate(ghostCatPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity);
120
+ Assert.IsNotNull(ghostCatInstance, "Failed to instantiate the Ghost_Cat prefab.");
121
+
122
+ // Get the Enemy component
123
+ Enemy enemyComponent = ghostCatInstance.GetComponent<Enemy>();
124
+ Assert.IsNotNull(enemyComponent, "The Ghost_Cat instance does not have an Enemy component.");
125
+
126
+ // Create a wall object
127
+ GameObject wall = GameObject.CreatePrimitive(PrimitiveType.Cube);
128
+ wall.transform.position = new Vector3(ghostCatInstance.transform.position.x,
129
+ ghostCatInstance.transform.position.y + 0.5f, 1f);
130
+
131
+ // Add a Rigidbody and Collider component to ensure collision detection works
132
+ wall.AddComponent<BoxCollider>();
133
+ Rigidbody wallRigidbody = wall.AddComponent<Rigidbody>();
134
+ wallRigidbody.isKinematic = true;
135
+
136
+ // Start the Ghost_Cat moving towards the wall
137
+ enemyComponent.moveForward = true;
138
+
139
+ // Wait a few frames for the collision to occur
140
+ await WaitForSecondsUnity(2f);
141
+
142
+ // Check if the collision logic correctly stopped the movement or handled the collision
143
+ Rigidbody ghostCatRigidbody = ghostCatInstance.GetComponent<Rigidbody>();
144
+ Assert.IsNotNull(ghostCatRigidbody, "The Ghost_Cat does not have a Rigidbody component for collision.");
145
+
146
+ // Validate collision response
147
+ Vector3 stopPosition = ghostCatInstance.transform.position;
148
+
149
+ // Ensure the object did not move further into the wall
150
+ Assert.LessOrEqual(stopPosition.z, wall.transform.position.z - 0.5f,
151
+ "The Ghost_Cat did not stop correctly after colliding with the wall.");
152
+
153
+ // Stop the character to see where it ended up.
154
+ enemyComponent.moveForward = false;
155
+ }
156
+
157
+ /// <summary>
158
+ /// Tests the "Falling" mechanic, ensuring the object detects falling off the ground.
159
+ /// </summary>
160
+ [Test]
161
+ public async Task TestFalling()
162
+ {
163
+ // Load the "Ghost_Cat" prefab from the Resources folder
164
+ GameObject ghostCatPrefab = Resources.Load<GameObject>("Ghost_Cat");
165
+ Assert.IsNotNull(ghostCatPrefab, "The Ghost_Cat prefab could not be found in the Resources folder.");
166
+
167
+ // Spawn the "Ghost_Cat" prefab into the scene
168
+ GameObject ghostCatInstance =
169
+ Object.Instantiate(ghostCatPrefab, new Vector3(0f, 2f, 0f), Quaternion.identity);
170
+ Assert.IsNotNull(ghostCatInstance, "Failed to instantiate the Ghost_Cat prefab.");
171
+
172
+ // Get the Enemy component
173
+ Enemy enemyComponent = ghostCatInstance.GetComponent<Enemy>();
174
+ Assert.IsNotNull(enemyComponent, "The Ghost_Cat instance does not have an Enemy component.");
175
+
176
+ // Create a wall object
177
+ GameObject wall = GameObject.CreatePrimitive(PrimitiveType.Cube);
178
+ wall.transform.position =
179
+ new Vector3(ghostCatInstance.transform.position.x, 0.5f,
180
+ 0.5f); // Position the wall directly in front of the Ghost_Cat
181
+
182
+ // Add a Rigidbody and Collider component to ensure collision detection works
183
+ wall.AddComponent<BoxCollider>();
184
+ Rigidbody wallRigidbody = wall.AddComponent<Rigidbody>();
185
+ wallRigidbody.isKinematic = true;
186
+
187
+ // Start the Ghost_Cat moving towards the wall
188
+ enemyComponent.moveForward = true;
189
+
190
+ // Wait for the next frame to begin falling simulation
191
+ await Task.Yield();
192
+
193
+ // Simulate falling for 2 seconds
194
+ float initialY = ghostCatInstance.transform.position.y;
195
+ await WaitForSecondsUnity(2f);
196
+
197
+ // Stop the character after simulation ends
198
+ enemyComponent.moveForward = false;
199
+
200
+ // Check if the object has fallen below the original height
201
+ float finalY = ghostCatInstance.transform.position.y;
202
+ Assert.Less(finalY, 0.3f, "The Ghost_Cat did not fall as expected.");
203
+ }
204
+
205
+ /// <summary>
206
+ /// Tests the "Dying" mechanic, ensuring the entity is destroyed or marked dead when health reaches zero.
207
+ /// </summary>
208
+ [Test]
209
+ public async Task TestDying()
210
+ {
211
+ // Load the "Ghost_Cat" prefab from the Resources folder
212
+ GameObject ghostCatPrefab = Resources.Load<GameObject>("Ghost_Cat");
213
+ Assert.IsNotNull(ghostCatPrefab, "The Ghost_Cat prefab could not be found in the Resources folder.");
214
+
215
+ // Spawn the "Ghost_Cat" prefab into the scene
216
+ GameObject ghostCatInstance =
217
+ Object.Instantiate(ghostCatPrefab, new Vector3(0f, 2f, 0f), Quaternion.identity);
218
+ Assert.IsNotNull(ghostCatInstance, "Failed to instantiate the Ghost_Cat prefab.");
219
+
220
+ // Get the Enemy component
221
+ Enemy enemyComponent = ghostCatInstance.GetComponent<Enemy>();
222
+ Assert.IsNotNull(enemyComponent, "The Ghost_Cat instance does not have an Enemy component.");
223
+
224
+ // Create a box object
225
+ GameObject box = GameObject.CreatePrimitive(PrimitiveType.Cube);
226
+ box.transform.position =
227
+ new Vector3(ghostCatInstance.transform.position.x, 0.5f,
228
+ 0.5f); // Position the wall directly in front of the Ghost_Cat
229
+
230
+ // Add a Rigidbody and Collider component to ensure collision detection works
231
+ box.AddComponent<BoxCollider>();
232
+ Rigidbody wallRigidbody = box.AddComponent<Rigidbody>();
233
+ wallRigidbody.isKinematic = true;
234
+
235
+ // Create a red block simulating fire
236
+ GameObject fire = GameObject.CreatePrimitive(PrimitiveType.Cube);
237
+ fire.name = "Fire"; // Rename the block to "Fire"
238
+ fire.transform.position =
239
+ new Vector3(ghostCatInstance.transform.position.x, 0f, 2.5f); // Position the block appropriately
240
+ fire.transform.localScale = new Vector3(1f, 1f, 3f); // Scale the box to 2 along the x-axis
241
+
242
+ // Change the color to red
243
+ fire.GetComponent<Renderer>().material.color = Color.red;
244
+
245
+ // Add a Box Collider to detect collisions
246
+ BoxCollider collider = fire.AddComponent<BoxCollider>();
247
+ collider.isTrigger = true; // Set the collider to be a trigger
248
+
249
+ // Add a custom FireComponent to handle collision logic
250
+ fire.AddComponent<FireComponent>();
251
+
252
+ // Start the Ghost_Cat moving towards the wall
253
+ enemyComponent.moveForward = true;
254
+
255
+ // Wait for the next frame to begin the simulation
256
+ await Task.Yield();
257
+
258
+ // Simulate falling for 7 seconds
259
+ float initialY = ghostCatInstance.transform.position.y;
260
+ await WaitForSecondsUnity(7f);
261
+
262
+ // Stop the character after simulation ends
263
+ enemyComponent.moveForward = false;
264
+
265
+ // Check if the entity is destroyed or marked as "dead"
266
+ Assert.IsTrue(ghostCatInstance == null || !ghostCatInstance.activeSelf,
267
+ "The Ghost_Cat was not destroyed or deactivated.");
268
+ }
269
+
270
+ /// <summary>
271
+ /// Tests falling off the map boundaries and validates appropriate handling.
272
+ /// </summary>
273
+ [Test]
274
+ public async Task TestBoundaryDetection()
275
+ {
276
+ // Load the "Ghost_Cat" prefab from the Resources folder
277
+ GameObject ghostCatPrefab = Resources.Load<GameObject>("Ghost_Cat");
278
+ Assert.IsNotNull(ghostCatPrefab, "The Ghost_Cat prefab could not be found in the Resources folder.");
279
+
280
+ // Spawn the "Ghost_Cat" prefab into the scene
281
+ GameObject ghostCatInstance =
282
+ Object.Instantiate(ghostCatPrefab, new Vector3(0f, 1f, 0f), Quaternion.Euler(0, 180, 0));
283
+ Assert.IsNotNull(ghostCatInstance, "Failed to instantiate the Ghost_Cat prefab.");
284
+
285
+ // Get the Enemy component
286
+ Enemy enemyComponent = ghostCatInstance.GetComponent<Enemy>();
287
+ Assert.IsNotNull(enemyComponent, "The Ghost_Cat instance does not have an Enemy component.");
288
+
289
+ // Start the Ghost_Cat moving towards the wall
290
+ enemyComponent.moveForward = true;
291
+
292
+ // Wait for the next frame to begin the simulation
293
+ await Task.Yield();
294
+
295
+ // Simulate falling for 3 seconds
296
+ await WaitForSecondsUnity(3f);
297
+
298
+ // Stop the character after simulation
299
+ enemyComponent.moveForward = false;
300
+
301
+ // Check if the entity is destroyed or marked as "dead"
302
+ Assert.IsTrue(ghostCatInstance == null || !ghostCatInstance.activeSelf,
303
+ "The Ghost_Cat was not destroyed or deactivated as expected after falling off the map.");
304
+ }
305
+
306
+ }
307
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: fc6813e7bf8e2b147ae669f90e7c4c7f
3
+ timeCreated: 1742466392
@@ -0,0 +1,157 @@
1
+ %YAML 1.1
2
+ %TAG !u! tag:unity3d.com,2011:
3
+ --- !u!1001 &7559842864294337587
4
+ PrefabInstance:
5
+ m_ObjectHideFlags: 0
6
+ serializedVersion: 2
7
+ m_Modification:
8
+ serializedVersion: 3
9
+ m_TransformParent: {fileID: 0}
10
+ m_Modifications:
11
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
12
+ type: 3}
13
+ propertyPath: m_LocalPosition.x
14
+ value: 0
15
+ objectReference: {fileID: 0}
16
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
17
+ type: 3}
18
+ propertyPath: m_LocalPosition.y
19
+ value: 0
20
+ objectReference: {fileID: 0}
21
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
22
+ type: 3}
23
+ propertyPath: m_LocalPosition.z
24
+ value: 0
25
+ objectReference: {fileID: 0}
26
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
27
+ type: 3}
28
+ propertyPath: m_LocalRotation.w
29
+ value: 1
30
+ objectReference: {fileID: 0}
31
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
32
+ type: 3}
33
+ propertyPath: m_LocalRotation.x
34
+ value: 0
35
+ objectReference: {fileID: 0}
36
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
37
+ type: 3}
38
+ propertyPath: m_LocalRotation.y
39
+ value: 0
40
+ objectReference: {fileID: 0}
41
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
42
+ type: 3}
43
+ propertyPath: m_LocalRotation.z
44
+ value: 0
45
+ objectReference: {fileID: 0}
46
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
47
+ type: 3}
48
+ propertyPath: m_LocalEulerAnglesHint.x
49
+ value: 0
50
+ objectReference: {fileID: 0}
51
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
52
+ type: 3}
53
+ propertyPath: m_LocalEulerAnglesHint.y
54
+ value: 0
55
+ objectReference: {fileID: 0}
56
+ - target: {fileID: -8679921383154817045, guid: 11f102f6c7bba8348be5b03d99bb9022,
57
+ type: 3}
58
+ propertyPath: m_LocalEulerAnglesHint.z
59
+ value: 0
60
+ objectReference: {fileID: 0}
61
+ - target: {fileID: 919132149155446097, guid: 11f102f6c7bba8348be5b03d99bb9022,
62
+ type: 3}
63
+ propertyPath: m_Name
64
+ value: Ghost_cat
65
+ objectReference: {fileID: 0}
66
+ - target: {fileID: 5866666021909216657, guid: 11f102f6c7bba8348be5b03d99bb9022,
67
+ type: 3}
68
+ propertyPath: m_Controller
69
+ value:
70
+ objectReference: {fileID: 9100000, guid: 071cb03b36e6c0144a8a4745a246bf30, type: 2}
71
+ m_RemovedComponents: []
72
+ m_RemovedGameObjects: []
73
+ m_AddedGameObjects: []
74
+ m_AddedComponents:
75
+ - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 11f102f6c7bba8348be5b03d99bb9022,
76
+ type: 3}
77
+ insertIndex: -1
78
+ addedObject: {fileID: 8469286317268006426}
79
+ - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 11f102f6c7bba8348be5b03d99bb9022,
80
+ type: 3}
81
+ insertIndex: -1
82
+ addedObject: {fileID: 1609703187268855999}
83
+ - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 11f102f6c7bba8348be5b03d99bb9022,
84
+ type: 3}
85
+ insertIndex: -1
86
+ addedObject: {fileID: 2043454299057987180}
87
+ m_SourcePrefab: {fileID: 100100000, guid: 11f102f6c7bba8348be5b03d99bb9022, type: 3}
88
+ --- !u!1 &7217190862441423202 stripped
89
+ GameObject:
90
+ m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 11f102f6c7bba8348be5b03d99bb9022,
91
+ type: 3}
92
+ m_PrefabInstance: {fileID: 7559842864294337587}
93
+ m_PrefabAsset: {fileID: 0}
94
+ --- !u!136 &8469286317268006426
95
+ CapsuleCollider:
96
+ m_ObjectHideFlags: 0
97
+ m_CorrespondingSourceObject: {fileID: 0}
98
+ m_PrefabInstance: {fileID: 0}
99
+ m_PrefabAsset: {fileID: 0}
100
+ m_GameObject: {fileID: 7217190862441423202}
101
+ m_Material: {fileID: 0}
102
+ m_IncludeLayers:
103
+ serializedVersion: 2
104
+ m_Bits: 0
105
+ m_ExcludeLayers:
106
+ serializedVersion: 2
107
+ m_Bits: 0
108
+ m_LayerOverridePriority: 0
109
+ m_IsTrigger: 0
110
+ m_ProvidesContacts: 0
111
+ m_Enabled: 1
112
+ serializedVersion: 2
113
+ m_Radius: 0.34
114
+ m_Height: 2.22
115
+ m_Direction: 1
116
+ m_Center: {x: 0, y: 1.11, z: 0}
117
+ --- !u!54 &1609703187268855999
118
+ Rigidbody:
119
+ m_ObjectHideFlags: 0
120
+ m_CorrespondingSourceObject: {fileID: 0}
121
+ m_PrefabInstance: {fileID: 0}
122
+ m_PrefabAsset: {fileID: 0}
123
+ m_GameObject: {fileID: 7217190862441423202}
124
+ serializedVersion: 4
125
+ m_Mass: 1
126
+ m_Drag: 0
127
+ m_AngularDrag: 0.05
128
+ m_CenterOfMass: {x: 0, y: 0, z: 0}
129
+ m_InertiaTensor: {x: 1, y: 1, z: 1}
130
+ m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
131
+ m_IncludeLayers:
132
+ serializedVersion: 2
133
+ m_Bits: 0
134
+ m_ExcludeLayers:
135
+ serializedVersion: 2
136
+ m_Bits: 0
137
+ m_ImplicitCom: 1
138
+ m_ImplicitTensor: 1
139
+ m_UseGravity: 1
140
+ m_IsKinematic: 0
141
+ m_Interpolate: 0
142
+ m_Constraints: 0
143
+ m_CollisionDetection: 0
144
+ --- !u!114 &2043454299057987180
145
+ MonoBehaviour:
146
+ m_ObjectHideFlags: 0
147
+ m_CorrespondingSourceObject: {fileID: 0}
148
+ m_PrefabInstance: {fileID: 0}
149
+ m_PrefabAsset: {fileID: 0}
150
+ m_GameObject: {fileID: 7217190862441423202}
151
+ m_Enabled: 1
152
+ m_EditorHideFlags: 0
153
+ m_Script: {fileID: 11500000, guid: 5db73e440bac64f45b231ca31dfa95a3, type: 3}
154
+ m_Name:
155
+ m_EditorClassIdentifier:
156
+ moveSpeed: 1
157
+ moveForward: 0
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: b982276c235ddd942b8820d2129c283c
3
+ PrefabImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 33dc46c74df92df478816655f004e09f
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant: