public void Test_Map_Throws(string input) { //given var directionMapper = new DirectionLiteralsMapper(); var mapper = new MoveCommandToCoordinatesMapper(directionMapper); //when //then var ex = Assert.Throws <FormatException>(() => mapper.Map(input)); Assert.That(ex.Message, Is.EqualTo("Missing move command")); }
public void TestMap_CorrectInput_MappingIntoCoordinates(string input, string expected) { //given var directionMapper = new DirectionLiteralsMapper(); var mapper = new MoveCommandToCoordinatesMapper(directionMapper); //when var resut = mapper.Map(input); //then Assert.That(string.Join(',', resut.Select(r => $"({r.X};{r.Y})")), Is.EqualTo(expected)); }
public void TestMove_MoveOutTheBoard_LatestValidPositionReturned() { //given var directionMapper = new DirectionLiteralsMapper(); var gameboard = new Gameboard(5, 5, directionMapper); gameboard.Add(new Piece(0, 0, Direction.North)); //when var result = gameboard.MovePiece(new Point(0, 0), new Point(-1, 0)); //then Assert.That(result.Position, Is.EqualTo(new Point(0, 0))); Assert.That(result.Direction, Is.EqualTo(Direction.North)); }
public void TestMove_ExistingPicedMovedAndReturned() { //given var directionMapper = new DirectionLiteralsMapper(); var gameboard = new Gameboard(5, 5, directionMapper); gameboard.Add(new Piece(0, 0, Direction.North)); //when var result = gameboard.MovePiece(new Point(0, 0), new Point(1, 0)); //then Assert.That(result.Position, Is.EqualTo(new Point(1, 0))); Assert.That(result.Direction, Is.EqualTo(Direction.East)); }
public void TestPlay_ShouldReturnCorrectResut(string input, string expected) { //given var directionsMapper = new DirectionLiteralsMapper(); //TODO: Move directionsMapper as part of methods call and it will become a dependency into Game class var game = new Game( new Gameboard(5, 5, directionsMapper), new MoveCommandPathReducer(directionsMapper), new MoveCommandToCoordinatesMapper(directionsMapper), new DefaultResultFormatter(directionsMapper)); //when var result = game.Play(new Piece(0, 0, Direction.North), input, Direction.North); //then Assert.That(result.Result, Is.EqualTo(expected)); }