예제 #1
0
        public void FindingHexNeighbours_BothFunctions_ReturnSameResults([ValueSource("OddAndEvenInt2")] int2 pos, [Values(2, 3, 4, 5, 7)] int level)
        {
            var actual   = HexUtility.FindNeighbours(pos, level);
            var expected = HexUtility.DEPRECATE_FindNeighboursRecursive(pos, level);

            CollectionAssert.AreEquivalent(expected, actual);
        }
예제 #2
0
        public void FindingHexNeighbours_ReturnsCorrectNeighbours_ForLevel1_Odd()
        {
            var neighbours = HexUtility.FindNeighbours(new int2(1, 1));

            var expectedNneighbours = new[] { new int2(2, 1), new int2(0, 1), new int2(0, 2), new int2(1, 2), new int2(0, 0), new int2(1, 0) };

            CollectionAssert.AreEquivalent(expectedNneighbours, neighbours);
        }
예제 #3
0
        // This test is a bit slow, so doing both things, checking Covered Area and Computed path
        public void Pathfinder_CoveredCells_AndPathSize_AreCorrectOnEmptyMap([ValueSource("OddAndEvenInt2")] int2 cellFrom, [ValueSource("SomeRandomInt2")] int2 cellTo)
        {
            var c          = TestUtility.CreateContainer();
            var pathfinder = c.Resolve <IHexPathfinder>();

            var distance             = HexUtility.ManhattanDistance(cellFrom, cellTo);
            var coveredCellsExpected = HexUtility.FindNeighbours(cellFrom, distance);
            var pathMap            = pathfinder.FindAllPaths(cellFrom, HexType.Empty, distance);
            var coveredCellsActual = pathMap.CoveredCells();
            var pathToDestination  = pathMap.CalculatePath(cellTo);

            Assert.AreEqual(coveredCellsExpected.Length, coveredCellsActual.Count(), "Collection sizes were different");
            CollectionAssert.AreEquivalent(coveredCellsExpected, coveredCellsActual, "Elements inside were different");
            Assert.AreEqual(distance, pathToDestination.Count(), "Calculated path size was incorrect");
        }
예제 #4
0
        public void FindingHexNeighbours_ReturnsCorrectAmountOfNeighbours(int level, int amountOfNeighbours)
        {
            var neighbours = HexUtility.FindNeighbours(new int2(1, 1), level);

            Assert.AreEqual(amountOfNeighbours, neighbours.Length);
        }