public void TestMatrixIsIsChangeDirectionPossible() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); int matrixRang = 5; Matrix matrix = new Matrix(matrixRang, directionSet); int testValue = 2; for (int i = 0; i < matrixRang; i++) { matrix[i, 0] = testValue; } bool possibleChangeDirection = matrix.IsChangeDirectionPossible(1, 0); Assert.IsTrue(possibleChangeDirection); for (int i = 0; i < matrixRang; i++) { for (int j = 0; j < matrixRang; j++) { matrix[i, j] = testValue; } } bool impossibleChangeDirection = matrix.IsValidEmptyCell(1, 0); Assert.IsFalse(impossibleChangeDirection); }
public void TestGetDeltaIncreaseDecrease() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); Direction2D direction = new Direction2D(directionSet); int deltaX; int deltaY; direction.GetDelta(out deltaX, out deltaY); Assert.AreEqual(deltaX, 1); Assert.AreEqual(deltaY, 1); direction.Increase(); direction.Increase(); direction.GetDelta(out deltaX, out deltaY); Assert.AreEqual(deltaX, 1); Assert.AreEqual(deltaY, -1); direction.Decrease(); direction.GetDelta(out deltaX, out deltaY); Assert.AreEqual(deltaX, 1); Assert.AreEqual(deltaY, 0); }
public void TestMatrixIsValidEmptyCell() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); int matrixRang = 5; Matrix matrix = new Matrix(matrixRang, directionSet); int testValue = 2; for (int i = 0; i < matrixRang; i++) { matrix[i, 0] = testValue; } bool fullCellCheckResult = matrix.IsValidEmptyCell(0, 0); Assert.IsFalse(fullCellCheckResult); bool emptyCellCheckResult = matrix.IsValidEmptyCell(0, 3); Assert.IsTrue(emptyCellCheckResult); bool incorrectIndexCell = matrix.IsValidEmptyCell(0, 6); Assert.IsFalse(incorrectIndexCell); }
public void TestWalkEntireMatrix() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); int matrixRang = 5; Matrix matrix = new Matrix(matrixRang, directionSet); MatrixWalkEngine.WalkEntireMatrix(matrix); int[,] resultMatrix = { { 1, 13, 14, 15, 16 }, { 12, 2, 21, 22, 17 }, { 11, 23, 3, 20, 18 }, { 10, 25, 24, 4, 19 }, { 9, 8, 7, 6, 5 } }; for (int i = 0; i < matrixRang; i++) { for (int j = 0; j < matrixRang; j++) { Assert.AreEqual(matrix.Grid[i, j], resultMatrix[i, j]); } } }
public void TestMatrixCreation() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); Matrix matrix = new Matrix(5, directionSet); }
public void TestNumber() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); Direction2D direction = new Direction2D(directionSet); direction.Number = 10; }
public void TestMatrixIndexException() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); int matrixRang = 5; Matrix matrix = new Matrix(matrixRang, directionSet); int testValue = 2; matrix[20, 2] = testValue; }
public void TestMatrixIndex() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); int matrixRang = 5; Matrix matrix = new Matrix(matrixRang, directionSet); int testValue = 2; matrix[2, 2] = testValue; int resultTestValue = matrix[2, 2]; Assert.AreEqual(resultTestValue, 2); }
public void TestMatrixFindEmptyCell() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); int matrixRang = 5; Matrix matrix = new Matrix(matrixRang, directionSet); int testValue = 2; for (int i = 0; i < matrixRang; i++) { matrix[i, 0] = testValue; } int indexX; int indexY; bool foundEmptyCell = matrix.FindEmptyCell(out indexX, out indexY); Assert.IsTrue(foundEmptyCell); Assert.AreEqual(indexX, 0); Assert.AreEqual(indexY, 1); for (int i = 0; i < matrixRang; i++) { for (int j = 0; j < matrixRang; j++) { matrix[i, j] = testValue; } } foundEmptyCell = matrix.FindEmptyCell(out indexX, out indexY); Assert.IsFalse(foundEmptyCell); Assert.AreEqual(indexX, -1); Assert.AreEqual(indexY, -1); }
public void TestDirectionY() { int[] directionsX = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionsY = { 1, 0, -1, -1, -1, 0, 1 }; DirectionSet2D directionSet = new DirectionSet2D(8, directionsX, directionsY); }