< 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:40
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();
 1015    SimManager.Instance = simManager;
 1016  }
 17
 18  [TearDown]
 1019  public virtual void Teardown() {
 20    // Clean up SimManager
 1921    if (simManager != null) {
 922      GameObject.DestroyImmediate(simManager.gameObject);
 923    }
 1024  }
 25
 026  protected Interceptor CreateTestInterceptor(DynamicAgentConfig config) {
 027    Interceptor interceptor =
 28        InvokePrivateMethod<Interceptor>(simManager, "CreateInterceptor", config);
 029    InvokePrivateMethod(interceptor, "Start");
 030    InvokePrivateMethod(interceptor.gameObject.GetComponent<Sensor>(), "Start");
 031    return interceptor;
 032  }
 33
 1534  protected Threat CreateTestThreat(DynamicAgentConfig config) {
 1535    Threat threat = InvokePrivateMethod<Threat>(simManager, "CreateThreat", config);
 1536    InvokePrivateMethod(threat, "Start");
 1537    InvokePrivateMethod(threat.gameObject.GetComponent<Sensor>(), "Start");
 1538    return threat;
 1539  }
 40}