< Summary

Class:TransformationTests
Assembly:bamlab.test.editmode
File(s):/github/workspace/Assets/Tests/EditMode/TransformationTests.cs
Covered lines:0
Uncovered lines:61
Coverable lines:61
Total lines:101
Line coverage:0% (0 of 61)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:3
Method coverage:0% (0 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Target_At_Boresight()0%2100%
Target_At_Starboard()0%2100%
Target_At_Elevation()0%2100%

File(s)

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

#LineLine coverage
 1using NUnit.Framework;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.TestTools;
 5using System.Linq;
 6
 7public class TransformationTests : AgentTestBase {
 8  [Test]
 09  public void Target_At_Boresight() {
 10    // Create agent
 011    DummyAgent agent = new GameObject("Agent").AddComponent<DummyAgent>();
 012    Rigidbody agentRb = agent.gameObject.AddComponent<Rigidbody>();
 013    agent.transform.position = new Vector3(0, 0, 0);
 014    agentRb.linearVelocity = new Vector3(0, 0, 0);
 015    InvokePrivateMethod(agent, "Start");
 16
 17    // Create target
 018    DummyAgent target = new GameObject("Target").AddComponent<DummyAgent>();
 019    target.SetPosition(new Vector3(0, 0, 20));
 020    Rigidbody targetRb = target.gameObject.AddComponent<Rigidbody>();
 021    targetRb.linearVelocity = new Vector3(0, 20, -1);
 022    InvokePrivateMethod(target, "Start");
 23
 24    // Find the relative transformation to the target
 025    Transformation relativeTransformation = agent.GetRelativeTransformation(target);
 26
 27    // Assert
 028    Assert.AreEqual(relativeTransformation.position.cartesian,
 29                    target.transform.position - agent.transform.position);
 030    Assert.AreEqual(relativeTransformation.position.range, 20);
 031    Assert.AreEqual(relativeTransformation.position.azimuth, 0);
 032    Assert.AreEqual(relativeTransformation.position.elevation, 0);
 033    Assert.AreEqual(relativeTransformation.velocity.cartesian,
 34                    target.GetVelocity() - agent.GetVelocity());
 035    Assert.AreEqual(relativeTransformation.velocity.range, -1);
 036    Assert.AreEqual(relativeTransformation.velocity.azimuth, 0);
 037    Assert.AreEqual(relativeTransformation.velocity.elevation, 1);
 038  }
 39
 40  [Test]
 041  public void Target_At_Starboard() {
 42    // Create agent
 043    DummyAgent agent = new GameObject("Agent").AddComponent<DummyAgent>();
 044    Rigidbody agentRb = agent.gameObject.AddComponent<Rigidbody>();
 045    agent.transform.position = new Vector3(0, 0, 0);
 046    agentRb.linearVelocity = new Vector3(0, 0, 0);
 47
 48    // Create target
 049    DummyAgent target = new GameObject("Target").AddComponent<DummyAgent>();
 050    target.SetPosition(new Vector3(20, 0, 0));
 051    Rigidbody targetRb = target.gameObject.AddComponent<Rigidbody>();
 052    targetRb.linearVelocity = new Vector3(0, 0, 20);
 53
 54    // Find the relative transformation to the target
 055    Transformation relativeTransformation = agent.GetRelativeTransformation(target);
 56
 57    // Assert
 058    Assert.AreEqual(relativeTransformation.position.cartesian,
 59                    target.transform.position - agent.transform.position);
 060    Assert.AreEqual(relativeTransformation.position.range, 20);
 061    Assert.AreEqual(relativeTransformation.position.azimuth, Mathf.PI / 2);
 062    Assert.AreEqual(relativeTransformation.position.elevation, 0);
 063    Assert.AreEqual(relativeTransformation.velocity.cartesian,
 64                    target.GetVelocity() - agent.GetVelocity());
 065    Assert.AreEqual(relativeTransformation.velocity.range, 0);
 066    Assert.AreEqual(relativeTransformation.velocity.azimuth, -1);
 067    Assert.AreEqual(relativeTransformation.velocity.elevation, 0);
 068  }
 69
 70  [Test]
 071  public void Target_At_Elevation() {
 72    // Create agent
 073    DummyAgent agent = new GameObject("Agent").AddComponent<DummyAgent>();
 074    Rigidbody agentRb = agent.gameObject.AddComponent<Rigidbody>();
 075    agent.transform.position = new Vector3(0, 0, 0);
 076    agentRb.linearVelocity = new Vector3(0, 0, 0);
 077    InvokePrivateMethod(agent, "Start");
 78
 79    // Create target
 080    DummyAgent target = new GameObject("Target").AddComponent<DummyAgent>();
 081    target.SetPosition(new Vector3(0, 20, 0));
 082    Rigidbody targetRb = target.gameObject.AddComponent<Rigidbody>();
 083    targetRb.linearVelocity = new Vector3(0, 0, 20);
 084    InvokePrivateMethod(target, "Start");
 85
 86    // Find the relative transformation to the target
 087    Transformation relativeTransformation = agent.GetRelativeTransformation(target);
 88
 89    // Assert
 090    Assert.AreEqual(relativeTransformation.position.cartesian,
 91                    target.transform.position - agent.transform.position);
 092    Assert.AreEqual(relativeTransformation.position.range, 20);
 093    Assert.AreEqual(relativeTransformation.position.azimuth, 0);
 094    Assert.AreEqual(relativeTransformation.position.elevation, Mathf.PI / 2);
 095    Assert.AreEqual(relativeTransformation.velocity.cartesian,
 96                    target.GetVelocity() - agent.GetVelocity());
 097    Assert.AreEqual(relativeTransformation.velocity.range, 0);
 098    Assert.AreEqual(relativeTransformation.velocity.azimuth, 0);
 099    Assert.AreEqual(relativeTransformation.velocity.elevation, -1);
 0100  }
 101}