| | 1 | | using System; |
| | 2 | | using System.Reflection; |
| | 3 | | using NUnit.Framework; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public abstract class AgentTestBase : TestBase { |
| | 7 | | protected SimManager simManager; |
| | 8 | |
|
| | 9 | | [SetUp] |
| 0 | 10 | | public virtual void Setup() { |
| | 11 | | // Initialize SimManager |
| 0 | 12 | | var simManagerGameObject = new GameObject("SimManager"); |
| 0 | 13 | | simManager = simManagerGameObject.AddComponent<SimManager>(); |
| 0 | 14 | | simManager.simulationConfig = new SimulationConfig(); // Set up a basic config if needed |
| | 15 | |
|
| 0 | 16 | | SimManager.Instance = simManager; |
| 0 | 17 | | } |
| | 18 | |
|
| | 19 | | [TearDown] |
| 0 | 20 | | public virtual void Teardown() { |
| | 21 | | // Clean up SimManager |
| 0 | 22 | | if (simManager != null) { |
| 0 | 23 | | GameObject.DestroyImmediate(simManager.gameObject); |
| 0 | 24 | | } |
| 0 | 25 | | } |
| | 26 | |
|
| 0 | 27 | | protected Interceptor CreateTestInterceptor(DynamicAgentConfig config) { |
| 0 | 28 | | Interceptor interceptor = |
| | 29 | | InvokePrivateMethod<Interceptor>(simManager, "CreateInterceptor", config); |
| 0 | 30 | | InvokePrivateMethod(interceptor, "Start"); |
| 0 | 31 | | InvokePrivateMethod(interceptor.gameObject.GetComponent<Sensor>(), "Start"); |
| 0 | 32 | | return interceptor; |
| 0 | 33 | | } |
| | 34 | |
|
| 0 | 35 | | protected Threat CreateTestThreat(DynamicAgentConfig config) { |
| 0 | 36 | | Threat threat = InvokePrivateMethod<Threat>(simManager, "CreateThreat", config); |
| 0 | 37 | | InvokePrivateMethod(threat, "Start"); |
| 0 | 38 | | InvokePrivateMethod(threat.gameObject.GetComponent<Sensor>(), "Start"); |
| 0 | 39 | | return threat; |
| 0 | 40 | | } |
| | 41 | | } |