< Summary

Class:LinearExtrapolatorTest
Assembly:bamlab.test.editmode
File(s):/github/workspace/Assets/Tests/EditMode/LinearExtrapolatorTest.cs
Covered lines:28
Uncovered lines:0
Coverable lines:28
Total lines:42
Line coverage:100% (28 of 28)
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
GenerateAgent()0%110100%
TestPresent()0%110100%
TestPast()0%110100%
TestFuture()0%110100%

File(s)

/github/workspace/Assets/Tests/EditMode/LinearExtrapolatorTest.cs

#LineLine coverage
 1using NUnit.Framework;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5using UnityEngine.TestTools;
 6
 7public class LinearExtrapolatorTest {
 38  public static Agent GenerateAgent() {
 39    Agent agent = new GameObject().AddComponent<DummyAgent>();
 310    Rigidbody rb = agent.gameObject.AddComponent<Rigidbody>();
 311    agent.transform.position = new Vector3(10, 0, 5);
 312    rb.linearVelocity = new Vector3(1, -2, 2);
 313    return agent;
 314  }
 15
 16  [Test]
 117  public void TestPresent() {
 118    Agent agent = GenerateAgent();
 119    LinearExtrapolator predictor = new LinearExtrapolator(agent);
 120    PredictorState predictedState = predictor.Predict(time: 0f);
 121    Assert.AreEqual(agent.GetPosition(), predictedState.Position);
 122    Assert.AreEqual(agent.GetVelocity(), predictedState.Velocity);
 123  }
 24
 25  [Test]
 126  public void TestPast() {
 127    Agent agent = GenerateAgent();
 128    LinearExtrapolator predictor = new LinearExtrapolator(agent);
 129    PredictorState predictedState = predictor.Predict(time: -5f);
 130    Assert.AreEqual(new Vector3(5, 10, -5), predictedState.Position);
 131    Assert.AreEqual(agent.GetVelocity(), predictedState.Velocity);
 132  }
 33
 34  [Test]
 135  public void TestFuture() {
 136    Agent agent = GenerateAgent();
 137    LinearExtrapolator predictor = new LinearExtrapolator(agent);
 138    PredictorState predictedState = predictor.Predict(time: 10f);
 139    Assert.AreEqual(new Vector3(20, -20, 25), predictedState.Position);
 140    Assert.AreEqual(agent.GetVelocity(), predictedState.Velocity);
 141  }
 42}