public void Should_return_an_error_if_there_is_an_invalid_movement() { const string movementsArgs = "RMLMA"; var moveParser = new MovementsParser(); moveParser.Invoking(x => x.Parse(movementsArgs)).Should().Throw <InvalidMovementException>(); }
public void KnightCanValidateMovementsTheory(string movementString) { // Arrange Knight knight = new Knight(); Exception expectedError = null; Movement movement = new Movement() { MovementInputString = movementString, PieceType = MovementsParser.getTypeFromCharacter(movementString[0]), OriginCell = new Cell() { Row = MovementsParser.getRowFromSecondCharacterInMovement(movementString[2]), Column = MovementsParser.getColumnFromFirstCharacterInMovement(movementString[1]) }, DestinationCell = new Cell() { Row = MovementsParser.getRowFromSecondCharacterInMovement(movementString[5]), Column = MovementsParser.getColumnFromFirstCharacterInMovement(movementString[4]) } }; // Act try { knight.ProcessMovement(movement, chessBoard); } catch (Exception ex) { expectedError = ex; } // Assert Assert.Null(expectedError); }
static void Main(string[] args) { Piece[,] chessBoard = new Piece[, ] { { null, null, null, null, null, null, null, new Piece { Color = Color.White, Type = Models.Type.Rook } }, { null, null, new Piece { Color = Color.Black, Type = Models.Type.Pawn }, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, new Piece { Color = Color.White, Type = Models.Type.Knight }, null, null, null, null, null, new Piece { Color = Color.White, Type = Models.Type.Rook } }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, }; List <Movement> validMovements = MovementsParser.ParseFile("C:\\validMoves.txt"); List <Movement> invalidMovements = MovementsParser.ParseFile("C:\\invalidMoves.txt"); Console.WriteLine("*************************"); Console.WriteLine("* Movimiento Validos *"); Console.WriteLine("*************************"); ChessMovementsSimulator.SimulateMovements(chessBoard, validMovements); Console.WriteLine("*************************"); Console.WriteLine("* Movimiento Invalidos *"); Console.WriteLine("*************************"); ChessMovementsSimulator.SimulateMovements(chessBoard, invalidMovements); }
public void Should_receive_movements_in_a_string_and_return_a_list_with_individual_movements_preserving_the_sequence() { const string movements = "RMLM"; var moveParser = new MovementsParser(); var expectedMovements = new List <MovementType>() { MovementType.Right, MovementType.Forward, MovementType.Left, MovementType.Forward }; var parsed = moveParser.Parse(movements); parsed.SequenceEqual(expectedMovements).Should().BeTrue(); }