From 4839bfcb008b5d5e1504decb953089306f617983 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 13 Aug 2023 21:09:41 +0200 Subject: [PATCH] Minor style cleanup. --- tests/HexGridPathFindingTests.cs | 44 ++++++++++++++------------------ 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/tests/HexGridPathFindingTests.cs b/tests/HexGridPathFindingTests.cs index 60a1a8f..e78c826 100644 --- a/tests/HexGridPathFindingTests.cs +++ b/tests/HexGridPathFindingTests.cs @@ -1,15 +1,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using Godot; -using Godot.Collections; using GoDotTest; using Xunit; -using Array = System.Array; - -//using GodotXUnitApi; -//using Xunit; namespace GodotComponentTest.tests; @@ -18,14 +12,14 @@ public class HexGridPathFindingTests : TestClass private HexGrid _hexGrid; private HexCell _hexCell; - private HexCell _positionA = new HexCell(new Vector2(2, 0)); + private HexCell _positionA = new HexCell(new Vector2(2, 0)); private HexCell _positionB = new HexCell(new Vector2(4, 2)); private HexCell _positionC = new HexCell(new Vector2(7, 0)); private HexCell _positionD = new HexCell(new Vector2(5, 0)); private HexCell _positionE = new HexCell(new Vector2(2, 2)); private HexCell _positionF = new HexCell(new Vector2(1, 3)); private HexCell _positionG = new HexCell(new Vector2(1, 0)); - + private Vector2[] _obstacles = { new Vector2(2, 1), @@ -53,7 +47,7 @@ public class HexGridPathFindingTests : TestClass _hexGrid.AddObstacle(new HexCell(obstacle)); } } - + [Test] public void TestBounds() { @@ -61,7 +55,7 @@ public class HexGridPathFindingTests : TestClass Assert.Equal(_hexGrid.PathCostDefault, _hexGrid.GetHexCost(new Vector2(0, 4))); Assert.Equal(_hexGrid.PathCostDefault, _hexGrid.GetHexCost(new Vector2(7, 0))); Assert.Equal(_hexGrid.PathCostDefault, _hexGrid.GetHexCost(new Vector2(7, 4))); - + Assert.Equal(0, _hexGrid.GetHexCost(new Vector2(8, 2))); Assert.Equal(0, _hexGrid.GetHexCost(new Vector2(6, 5))); Assert.Equal(0, _hexGrid.GetHexCost(new Vector2(-1, 2))); @@ -73,7 +67,7 @@ public class HexGridPathFindingTests : TestClass { HexGrid grid = new HexGrid(); grid.SetBounds(new Vector2(-5, -5), new Vector2(-2, -2)); - + Assert.Equal(grid.PathCostDefault, grid.GetHexCost(new Vector2(-2, -2))); Assert.Equal(grid.PathCostDefault, grid.GetHexCost(new Vector2(-5, -5))); Assert.Equal(0, grid.GetHexCost(new Vector2(0, 0))); @@ -86,7 +80,7 @@ public class HexGridPathFindingTests : TestClass { HexGrid grid = new HexGrid(); grid.SetBounds(new Vector2(-3, -3), new Vector2(2, 2)); - + Assert.Equal(grid.PathCostDefault, grid.GetHexCost(new Vector2(-3, -3))); Assert.Equal(grid.PathCostDefault, grid.GetHexCost(new Vector2(2, 2))); Assert.Equal(grid.PathCostDefault, grid.GetHexCost(new Vector2(0, 0))); @@ -98,11 +92,11 @@ public class HexGridPathFindingTests : TestClass public void TestGridObstacles() { Assert.Equal(_obstacles.Length, _hexGrid.Obstacles.Count); - + // Adding an obstacle _hexGrid.AddObstacle(new HexCell(new Vector2(0, 0))); Assert.Equal(0, _hexGrid.Obstacles[new Vector2(0, 0)]); - + // Replacing obstacle _hexGrid.AddObstacle(new HexCell(new Vector2(0, 0)), 2); Assert.Equal(2, _hexGrid.Obstacles[new Vector2(0, 0)]); @@ -110,7 +104,7 @@ public class HexGridPathFindingTests : TestClass // Removing obstacle _hexGrid.RemoveObstacle(new HexCell(new Vector2(0, 0))); Assert.DoesNotContain(new Vector2(0, 0), _hexGrid.Obstacles); - + // Removing invalid does not cause error _hexGrid.RemoveObstacle(new HexCell(new Vector2(0, 0))); } @@ -119,10 +113,10 @@ public class HexGridPathFindingTests : TestClass public void TestHexCost() { Assert.Equal(_hexGrid.PathCostDefault, _hexGrid.GetHexCost(new Vector2(1, 1))); - Assert.Equal(0, _hexGrid.GetHexCost(new HexCell(new Vector3 (2, 1, -3)))); - + Assert.Equal(0, _hexGrid.GetHexCost(new HexCell(new Vector3(2, 1, -3)))); + _hexGrid.AddObstacle(new HexCell(1, 1), 1.337f); - Assert.Equal(1.337f, _hexGrid.GetHexCost(new Vector2(1,1))); + Assert.Equal(1.337f, _hexGrid.GetHexCost(new Vector2(1, 1))); } [Test] @@ -140,7 +134,7 @@ public class HexGridPathFindingTests : TestClass Assert.Single(_hexGrid.Barriers); _hexGrid.AddBarrier(new Vector2(0, 1), HexCell.DIR_S, 8); Assert.Equal(2, _hexGrid.Barriers.Count); - + Assert.Equal(14, _hexGrid.GetMoveCost(new Vector2(0, 0), HexCell.DIR_N)); } @@ -155,7 +149,7 @@ public class HexGridPathFindingTests : TestClass Assert.Equal(expectedCell.AxialCoords, pathCell.AxialCoords); } } - + [Test] public void TestStraightLine() { @@ -204,7 +198,7 @@ public class HexGridPathFindingTests : TestClass ComparePath(expectedPath, _hexGrid.FindPath(expectedPath.First(), expectedPath.Last())); } - + [Test] public void TestWalls() { @@ -222,7 +216,7 @@ public class HexGridPathFindingTests : TestClass { _hexGrid.AddBarrier(_positionG, wall); } - + List expectedPath = new List() { _positionA, @@ -240,7 +234,7 @@ public class HexGridPathFindingTests : TestClass { _hexGrid.AddBarrier(_positionG, HexCell.DIR_NE, 3); _hexGrid.AddBarrier(_positionG, HexCell.DIR_N, _hexGrid.PathCostDefault - 0.1f); - + List expectedPath = new List() { _positionA, @@ -263,7 +257,7 @@ public class HexGridPathFindingTests : TestClass new HexCell(new Vector2(5, 1)), _positionB, }; - + List longPath = new List() { _positionA, @@ -279,7 +273,7 @@ public class HexGridPathFindingTests : TestClass _hexGrid.PathCostDefault = 1f; ComparePath(shortPath, _hexGrid.FindPath(shortPath.First(), shortPath.Last())); - + _hexGrid.PathCostDefault = 2f; ComparePath(shortPath, _hexGrid.FindPath(shortPath.First(), shortPath.Last()));