From a704247aff6ae0f47e217981c870c61371be8c60 Mon Sep 17 00:00:00 2001 From: ben_pollard Date: Sun, 8 Dec 2024 18:28:07 +0000 Subject: [PATCH] Improved coverage of Matrix --- NetAF.Tests/Assets/Locations/Matrix_Tests.cs | 47 +++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/NetAF.Tests/Assets/Locations/Matrix_Tests.cs b/NetAF.Tests/Assets/Locations/Matrix_Tests.cs index 5321a15..c5ffa1e 100644 --- a/NetAF.Tests/Assets/Locations/Matrix_Tests.cs +++ b/NetAF.Tests/Assets/Locations/Matrix_Tests.cs @@ -144,6 +144,51 @@ public void Given1RoomOnZ1_WhenFindAllRoomsOnZ_Then1Room() [TestMethod] public void Given2Point1UnitApart_WhenDistanceBetweenPoints_Then1() + { + List roomPositions = + [ + new(new(string.Empty, string.Empty), new Point3D(0, 0, 0)), + new(new(string.Empty, string.Empty), new Point3D(0, 1, 0)) + ]; + var matrix = new Matrix([.. roomPositions]); + + var result = matrix.DistanceBetweenRooms(roomPositions[0].Room, roomPositions[1].Room); + + Assert.AreEqual(1, (int)result); + } + + [TestMethod] + public void GivenANull_WhenDistanceBetweenPoints_Then0() + { + List roomPositions = + [ + new(new(string.Empty, string.Empty), new Point3D(0, 0, 0)), + new(new(string.Empty, string.Empty), new Point3D(0, 1, 0)) + ]; + var matrix = new Matrix([.. roomPositions]); + + var result = matrix.DistanceBetweenRooms(null, roomPositions[1].Room); + + Assert.AreEqual(0, (int)result); + } + + [TestMethod] + public void GivenBNull_WhenDistanceBetweenPoints_Then0() + { + List roomPositions = + [ + new(new(string.Empty, string.Empty), new Point3D(0, 0, 0)), + new(new(string.Empty, string.Empty), new Point3D(0, 1, 0)) + ]; + var matrix = new Matrix([.. roomPositions]); + + var result = matrix.DistanceBetweenRooms(roomPositions[0].Room, null); + + Assert.AreEqual(0, (int)result); + } + + [TestMethod] + public void Given2Point1UnitApart_WhenDistanceBetweenRooms_Then1() { Point3D a = new(0, 0, 0); Point3D b = new(1, 0, 0); @@ -154,7 +199,7 @@ public void Given2Point1UnitApart_WhenDistanceBetweenPoints_Then1() } [TestMethod] - public void GivenVisitedRoomOn1And1VisitedRoomOn3_When_ThenReturnContaining1And3() + public void GivenVisitedRoomOn1And1VisitedRoomOn3_WhenFindAllZWithVisitedRooms_ThenReturnContaining1And3() { List roomPositions = [