| | 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] |
| 10 | 10 | | public virtual void Setup() { |
| | 11 | | // Initialize SimManager |
| 10 | 12 | | var simManagerGameObject = new GameObject("SimManager"); |
| 10 | 13 | | simManager = simManagerGameObject.AddComponent<SimManager>(); |
| 10 | 14 | | simManager.simulationConfig = new SimulationConfig(); // Set up a basic config if needed |
| | 15 | |
|
| 10 | 16 | | SimManager.Instance = simManager; |
| 10 | 17 | | } |
| | 18 | |
|
| | 19 | | [TearDown] |
| 10 | 20 | | public virtual void Teardown() { |
| | 21 | | // Clean up SimManager |
| 19 | 22 | | if (simManager != null) { |
| 9 | 23 | | GameObject.DestroyImmediate(simManager.gameObject); |
| 9 | 24 | | } |
| 10 | 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 | |
|
| 15 | 35 | | protected Threat CreateTestThreat(DynamicAgentConfig config) { |
| 15 | 36 | | Threat threat = InvokePrivateMethod<Threat>(simManager, "CreateThreat", config); |
| 15 | 37 | | InvokePrivateMethod(threat, "Start"); |
| 15 | 38 | | InvokePrivateMethod(threat.gameObject.GetComponent<Sensor>(), "Start"); |
| 15 | 39 | | return threat; |
| 15 | 40 | | } |
| | 41 | | } |