< Summary

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

Metrics

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

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]
 010  public virtual void Setup() {
 11    // Initialize the simulation manager.
 012    var simManagerGameObject = new GameObject("SimManager");
 013    _simManager = simManagerGameObject.AddComponent<SimManager>();
 014    _simManager.SimulationConfig = new Configs.SimulationConfig();
 015    SimManager.Instance = _simManager;
 016  }
 17
 18  [TearDown]
 019  public virtual void Teardown() {
 20    // Clean up the simulation manager.
 021    if (_simManager != null) {
 022      GameObject.DestroyImmediate(_simManager.gameObject);
 023    }
 024  }
 25
 026  protected Interceptor CreateTestInterceptor(Configs.AgentConfig config) {
 027    Interceptor interceptor = SimManager.Instance.CreateInterceptor(
 28        config, new Simulation.State() { Position = Coordinates3.ToProto(Vector3.zero),
 29                                         Velocity = Coordinates3.ToProto(Vector3.zero) });
 030    InvokePrivateMethod(interceptor, "Start");
 031    InvokePrivateMethod(interceptor.gameObject.GetComponent<Sensor>(), "Start");
 032    return interceptor;
 033  }
 34
 035  protected Threat CreateTestThreat(Configs.AgentConfig config) {
 036    Threat threat = SimManager.Instance.CreateThreat(config);
 037    InvokePrivateMethod(threat, "Start");
 038    InvokePrivateMethod(threat.gameObject.GetComponent<Sensor>(), "Start");
 039    return threat;
 040  }
 41}