< Summary

Class:AgentTestBase
Assembly:bamlab.test
File(s):/github/workspace/Assets/Tests/AgentTestBase.cs
Covered lines:17
Uncovered lines:6
Coverable lines:23
Total lines:41
Line coverage:73.9% (17 of 23)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:4
Method coverage:75% (3 of 4)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Setup()0%110100%
Teardown()0%220100%
CreateTestInterceptor(...)0%2100%
CreateTestThreat(...)0%110100%

File(s)

/github/workspace/Assets/Tests/AgentTestBase.cs

#LineLine coverage
 1using System;
 2using System.Reflection;
 3using NUnit.Framework;
 4using UnityEngine;
 5
 6public abstract class AgentTestBase : TestBase {
 7  protected SimManager simManager;
 8
 9  [SetUp]
 1010  public virtual void Setup() {
 11    // Initialize SimManager
 1012    var simManagerGameObject = new GameObject("SimManager");
 1013    simManager = simManagerGameObject.AddComponent<SimManager>();
 1014    simManager.simulationConfig = new SimulationConfig();  // Set up a basic config if needed
 15
 1016    SimManager.Instance = simManager;
 1017  }
 18
 19  [TearDown]
 1020  public virtual void Teardown() {
 21    // Clean up SimManager
 1922    if (simManager != null) {
 923      GameObject.DestroyImmediate(simManager.gameObject);
 924    }
 1025  }
 26
 027  protected Interceptor CreateTestInterceptor(DynamicAgentConfig config) {
 028    Interceptor interceptor =
 29        InvokePrivateMethod<Interceptor>(simManager, "CreateInterceptor", config);
 030    InvokePrivateMethod(interceptor, "Start");
 031    InvokePrivateMethod(interceptor.gameObject.GetComponent<Sensor>(), "Start");
 032    return interceptor;
 033  }
 34
 1535  protected Threat CreateTestThreat(DynamicAgentConfig config) {
 1536    Threat threat = InvokePrivateMethod<Threat>(simManager, "CreateThreat", config);
 1537    InvokePrivateMethod(threat, "Start");
 1538    InvokePrivateMethod(threat.gameObject.GetComponent<Sensor>(), "Start");
 1539    return threat;
 1540  }
 41}