public void TestKing_Position() { for (int i = 0; i < 100; i++) { Random random = new Random(); int row = random.Next(0, 7); int col = random.Next(0, 7); Position position = new Position(row, col); King king = new King(position); Assert.AreEqual<Position>(king.Position, position, "King`s position is not working correctly"); } }
public void TestPawnUpMoveInTableBorders() { List<Figure> figures = new List<Figure>(); figures.Add(new Pawn(new Position(0, 0), 'A')); figures.Add(new Pawn(new Position(0, 2), 'B')); figures.Add(new Pawn(new Position(0, 4), 'C')); Pawn newPawn = new Pawn(new Position(3, 4), 'D'); figures.Add(newPawn); King newKing = new King(new Position(4, 5)); figures.Add(newKing); GameBoard gameBoard = new GameBoard(figures); Engine currentEngine = new Engine(gameBoard, figures); Position newPosition = currentEngine.GetNewCoordinates(newPawn, Direction.UR) ; Assert.IsFalse(currentEngine.ValidateCommand("DUR"), "You can't move in this direction"); }
public void TestPawnImpossibleMove() { List<Figure> figures = new List<Figure>(); figures.Add(new Pawn(new Position(0, 0), 'A')); figures.Add(new Pawn(new Position(0, 2), 'B')); figures.Add(new Pawn(new Position(0, 4), 'C')); Pawn newPawn = new Pawn(new Position(3, 4), 'D'); figures.Add(newPawn); King newKing = new King(new Position(4, 5)); figures.Add(newKing); GameBoard gameBoard = new GameBoard(figures); Engine currentEngine = new Engine(gameBoard, figures); Position newPosition = currentEngine.GetNewCoordinates(newPawn, Direction.DR) ; Assert.IsNull(newPosition, "You can't move here,cell is busy"); }
public void TestPawnImpossibleOutOfBorderMove() { List<Figure> figures = new List<Figure>(); figures.Add(new Pawn(new Position(0, 0), 'A')); figures.Add(new Pawn(new Position(0, 2), 'B')); figures.Add(new Pawn(new Position(0, 4), 'C')); figures.Add(new Pawn(new Position(0, 6), 'D')); King newKing = new King(new Position(3, 7)); figures.Add(newKing); GameBoard gameBoard = new GameBoard(figures); Engine currentEngine = new Engine(gameBoard, figures); Assert.IsNull(currentEngine.GetNewCoordinates(newKing, Direction.UR), "You can't move here"); }
public void TestKingPossibleMove() { List<Figure> figures = new List<Figure>(); figures.Add(new Pawn(new Position(0, 0), 'A')); figures.Add(new Pawn(new Position(0, 2), 'B')); figures.Add(new Pawn(new Position(0, 4), 'C')); figures.Add(new Pawn(new Position(0, 6), 'D')); King newKing = new King(new Position(3, 7)); figures.Add(newKing); GameBoard gameBoard = new GameBoard(figures); Engine currentEngine = new Engine(gameBoard, figures); bool isNewPosition=(currentEngine.GetNewCoordinates(newKing, Direction.UL))is Position ; Assert.IsTrue(isNewPosition, "You can move here"); }