< Summary

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

Metrics

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

File(s)

/github/workspace/Assets/Tests/EditMode/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]
 1110  public virtual void Setup() {
 11    // Initialize the simulation manager.
 1112    var simManagerGameObject = new GameObject("SimManager");
 1113    _simManager = simManagerGameObject.AddComponent<SimManager>();
 1114    _simManager.SimulationConfig = new Configs.SimulationConfig();
 1115    SimManager.Instance = _simManager;
 1116  }
 17
 18  [TearDown]
 1119  public virtual void Teardown() {
 20    // Clean up the simulation manager.
 2121    if (_simManager != null) {
 1022      GameObject.DestroyImmediate(_simManager.gameObject);
 1023    }
 1124  }
 25
 126  protected Interceptor CreateTestInterceptor(Configs.AgentConfig config) {
 127    Interceptor interceptor = SimManager.Instance.CreateInterceptor(
 28        config, new Simulation.State() { Position = Coordinates3.ToProto(Vector3.zero),
 29                                         Velocity = Coordinates3.ToProto(Vector3.zero) });
 130    InvokePrivateMethod(interceptor, "Start");
 131    InvokePrivateMethod(interceptor.gameObject.GetComponent<Sensor>(), "Start");
 132    return interceptor;
 133  }
 34
 1535  protected Threat CreateTestThreat(Configs.AgentConfig config) {
 1536    Threat threat = SimManager.Instance.CreateThreat(config);
 1537    InvokePrivateMethod(threat, "Start");
 1538    InvokePrivateMethod(threat.gameObject.GetComponent<Sensor>(), "Start");
 1539    return threat;
 1540  }
 41}