public void VerifyMoveCauseCheck_BlackKingChecked_MoveToSavePosition_ShouldReturnFalse() { // arrange var board = new OrdinaryChessBoard(); var blackPawnRemove1Postion = new Position(1, 3); var blackPawnRemove2Postion = new Position(1, 4); var startWhiteQueenPosition = new Position(7, 3); var endWhiteQueenPosition = new Position(4, 0); var blackKingStartPosition = new Position(0, 4); var blackKingEndPosition = new Position(1, 4); board.RemoveFigure(blackPawnRemove1Postion); board.RemoveFigure(blackPawnRemove2Postion); var whiteQueen = board.RemoveFigure(startWhiteQueenPosition); whiteQueen.Move(endWhiteQueenPosition); board.SetFigure(whiteQueen, endWhiteQueenPosition); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act var result = verifier.VerifyMoveCauseCheck(blackKingStartPosition, blackKingEndPosition); // assert Assert.False(result); }
public void VerifyMoveCauseCheck_Knight_OtherFigureBlock_OK_ShouldReturnFalse() { // arrange var board = new OrdinaryChessBoard(); var knightStartPosition = new Position(0, 1); var knightEndPosition = new Position(2, 0); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act var result = verifier.VerifyMoveCauseCheck(knightStartPosition, knightEndPosition); // assert Assert.False(result); }
public void VerifyMoveCauseCheck_CannotMove_Rook_OtherFigureBlock_ShouldThrowException() { // arrange var board = new OrdinaryChessBoard(); var rookStartPosition = new Position(0, 0); var rookEndPosition = new Position(2, 0); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act // assert Assert.Throws <InvalidMoveException>(() => verifier.VerifyMoveCauseCheck(rookStartPosition, rookEndPosition)); }
public void VerifyMoveCauseCheck_CannotMove_InvalidMoveForFigure_ShouldThrowException() { // arrange var board = new OrdinaryChessBoard(); var knightStartPosition = new Position(0, 1); var knightEndPosition = new Position(5, 1); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act // assert Assert.Throws <InvalidMoveException>(() => verifier.VerifyMoveCauseCheck(knightStartPosition, knightEndPosition)); }
public void VerifyMoveCauseCheck_NoFigureAtPosition_ShouldThrowException() { // arrange var board = new OrdinaryChessBoard(); var pawnStartPosition = new Position(2, 0); var pawnEndPosition = new Position(3, 0); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act // assert Assert.Throws <RemoveFromBoardEmptyFieldException>(() => verifier.VerifyMoveCauseCheck(pawnStartPosition, pawnEndPosition)); }
public void VerifyMoveCauseCheck_MoveNotCauseCheck_ShouldReturnFalse() { // arrange var board = new OrdinaryChessBoard(); var pawnStartPosition = new Position(1, 0); var pawnEndPosition = new Position(2, 0); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act var result = verifier.VerifyMoveCauseCheck(pawnStartPosition, pawnEndPosition); // assert Assert.False(result); }
public void VerifyMoveCauseCheck_MoveBlackBishop_CheckWhiteKing_ShouldReturnTrue() { // arrange var board = new OrdinaryChessBoard(); var whiteRemovePawnPosition = new Position(6, 3); var blackRemovePawnPosition = new Position(1, 4); var blackBishopStartPosition = new Position(0, 5); var blackBishopEndPosition = new Position(4, 1); board.RemoveFigure(whiteRemovePawnPosition); board.RemoveFigure(blackRemovePawnPosition); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act var result = verifier.VerifyMoveCauseCheck(blackBishopStartPosition, blackBishopEndPosition); // assert Assert.True(result); }
public void VerifyMoveCauseCheck_MoveWhiteKnight_CheckBlackKing_ShouldReturnTrue() { // arrange var board = new OrdinaryChessBoard(); var whiteKnightStartPosition = new Position(7, 1); var whiteKnightMiddlePosition = new Position(4, 2); var whiteKnightEndPosition = new Position(2, 3); var knight = board.RemoveFigure(whiteKnightStartPosition); knight.Move(whiteKnightMiddlePosition); board.SetFigure(knight, whiteKnightMiddlePosition); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act var result = verifier.VerifyMoveCauseCheck(whiteKnightMiddlePosition, whiteKnightEndPosition); // assert Assert.True(result); }
public void VerifyMoveCauseCheck_BlackPawn_RevealsTheBlackKing_ShouldReturnTrue() { // arrange var board = new OrdinaryChessBoard(); var blackPawnStartPosition = new Position(1, 3); var blackPawnEndPosition = new Position(2, 3); var startWhiteQueenPosition = new Position(7, 3); var endWhiteQueenPosition = new Position(4, 0); var whiteQueen = board.RemoveFigure(startWhiteQueenPosition); whiteQueen.Move(endWhiteQueenPosition); board.SetFigure(whiteQueen, endWhiteQueenPosition); var moveValidator = new OrdinaryBoardMoveValidator(board); var verifier = new OrdinaryBoardCheckVerifier(board, moveValidator); // act var result = verifier.VerifyMoveCauseCheck(blackPawnStartPosition, blackPawnEndPosition); // assert Assert.True(result); }