public void TestCanMoveNumberTrue() { int fieldLength = 4; int fillCounter = 0; int[,] testMatrix = new int[fieldLength, fieldLength]; for (int x = 0; x < fieldLength; x++) { for (int y = 0; y < fieldLength; y++) { testMatrix[x, y] = fillCounter; fillCounter++; } } FieldInfo changedField = typeof(GameField).GetField("field", BindingFlags.Static | BindingFlags.NonPublic); changedField.SetValue(null, testMatrix); FieldInfo changedDict = typeof(GameField).GetField("NumbersAndPositions", BindingFlags.Static | BindingFlags.NonPublic); Coordinates testCooridates = new Coordinates(0, 1); Dictionary<int, Coordinates> testDict = new Dictionary<int, Coordinates>(); testDict.Add(1, testCooridates); testCooridates = new Coordinates(0, 0); testDict.Add(0, testCooridates); changedDict.SetValue(null, testDict); bool result = GameField.CanMoveNumber(1); Assert.IsTrue(result); }
public void TestForDublicatedPoints() { Coordinates currentPoint = new Coordinates(1, 1); Coordinates otherPoint = new Coordinates(1, 1); bool result = currentPoint.CheckNeighbour(otherPoint); }
public void TestConstructor() { Coordinates point = new Coordinates(3, 5); Assert.AreEqual(point.Row, 3); Assert.AreEqual(point.Col, 5); }
public void TestVerticalNeighbour() { Coordinates currentPoint = new Coordinates(1, 1); Coordinates otherPoint = new Coordinates(1, 2); bool result = currentPoint.CheckNeighbour(otherPoint); Assert.AreEqual(result, true); }
public void TestFarNeighbour() { Coordinates currentPoint = new Coordinates(1, 1); Coordinates otherPoint = new Coordinates(9, 9); bool result = currentPoint.CheckNeighbour(otherPoint); Assert.AreEqual(result, false); }
public void TestCanMoveNumberFalse() { FieldInfo changedDict = typeof(GameField).GetField("NumbersAndPositions", BindingFlags.Static | BindingFlags.NonPublic); Coordinates testCooridates = new Coordinates(0, 1); Dictionary<int, Coordinates> testDict = new Dictionary<int, Coordinates>(); testDict.Add(1, testCooridates); testCooridates = new Coordinates(1, 0); testDict.Add(0, testCooridates); changedDict.SetValue(null, testDict); bool result = GameField.CanMoveNumber(1); Assert.IsFalse(result); }
public bool CheckNeighbour(Coordinates other) { if (this.row == other.row && this.col == other.col) { throw new ArgumentException("Points cannot dublicate."); } bool checkLeft = this.CheckLeft(other); bool checkRight = this.CheckRight(other); bool checkTop = this.CheckTop(other); bool checkBottom = this.CheckBottom(other); if (checkLeft || checkRight || checkTop || checkBottom) { return true; } return false; }
private bool CheckLeft(Coordinates other) { bool checkLeft = this.Row == other.Row && this.Col == other.Col - 1; return checkLeft; }
private bool CheckBottom(Coordinates other) { bool checkBottom = this.Row == other.Row + 1 && this.Col == other.Col; return checkBottom; }
private bool CheckTop(Coordinates other) { bool checkTop = this.Row == other.Row - 1 && this.Col == other.Col; return checkTop; }
private bool CheckRight(Coordinates other) { bool checkRight = this.Row == other.Row && this.Col == other.Col + 1; return checkRight; }
public void TestRowWithNegativeValue() { Coordinates point = new Coordinates(-1, 4); }
public void TestColWithNegativeValue() { Coordinates point = new Coordinates(3, -4); }