12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Collections;
- using System.Collections.Generic;
- using CSVReader;
- using NUnit.Framework;
- using UnityEngine;
- using UnityEngine.TestTools;
- namespace Tests
- {
- public class MapSensorTest
- {
- IMapSensor mapper;
- private GameObject sensorDummy;
- [SetUp]
- public void SetUp()
- {
- sensorDummy = Resources.Load<GameObject>("Prefabs/Sensor");
- mapper = new MapSensor();
- }
- // A Test behaves as an ordinary method
- [Test]
- public void NoRotationDifference()
- {
- Dictionary<int, GameObject> sensors = new Dictionary<int, GameObject>();
- var instanceDummy = MonoBehaviour.Instantiate(sensorDummy);
- instanceDummy.transform.position = new Vector3(3, 0, 3);
- sensors.Add(0, instanceDummy);
- mapper.SetSensorList(sensors);
- InputObject input = new InputObject(0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, EntityType.PERSON, 0);
- var output = mapper.MapToWorldPositions(new List<InputObject>() { input });
- Assert.AreEqual(1, output.Count);
- Assert.AreEqual(0, Vector3.Distance(new Vector3(5, 0, 5), output[0].Pos), 0.00001);
- }
- [Test]
- public void WithRotationDifference()
- {
- Dictionary<int, GameObject> sensors = new Dictionary<int, GameObject>();
- var instanceDummy = MonoBehaviour.Instantiate(sensorDummy);
- instanceDummy.transform.position = new Vector3(3, 0, 3);
- //Rotate Lokal Grid 90Degress around Y axis
- instanceDummy.transform.rotation = Quaternion.AngleAxis(-90, Vector3.up);
- sensors.Add(0, instanceDummy);
- mapper.SetSensorList(sensors);
- InputObject input = new InputObject(0, 0, 2, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, EntityType.PERSON, 0);
- var output = mapper.MapToWorldPositions(new List<InputObject>() { input });
- Assert.AreEqual(1, output.Count);
- Assert.AreEqual(0, Vector3.Distance(new Vector3(5, 0, 5), output[0].Pos), 0.00001);
- }
- [Test]
- public void WithRotationDifferenceAndRotationOfObject()
- {
- Dictionary<int, GameObject> sensors = new Dictionary<int, GameObject>();
- var instanceDummy = MonoBehaviour.Instantiate(sensorDummy);
- instanceDummy.transform.position = new Vector3(3, 0, 3);
- //Rotate Lokal Grid 90Degress around Y axis
- instanceDummy.transform.rotation = Quaternion.AngleAxis(-90, Vector3.up);
- sensors.Add(0, instanceDummy);
- mapper.SetSensorList(sensors);
- InputObject input = new InputObject(0, 0, 2, 0, -2, 0, -90, 0, 0, 0, 0, 0, 0, EntityType.PERSON, 0);
- var output = mapper.MapToWorldPositions(new List<InputObject>() { input });
- Assert.AreEqual(1, output.Count);
- Assert.AreEqual(0, Vector3.Distance(new Vector3(0, -90, 0), output[0].Rot), 0.00001);
- }
- }
- }
|