### Question:
Bishop extends Figure { public Cell[] way(Cell source, Cell dest) throws ImpossibleMoveException { if (dest.getX() < 0 && dest.getY() < 0 && dest.getX() > 9 && dest.getY() > 9 && Math.abs(dest.getX() - source.getX()) != Math.abs(dest.getY() - source.getY())) { throw new ImpossibleMoveException("Слон так не ходит"); } Cell[] way = new Cell[8]; int wayPosition; int currentX = source.getX(); int currentY = source.getY(); int movesNumber = Math.abs(dest.getX() - source.getX()); int moveForX = source.getX() < dest.getX() ? 1 : -1; int moveForY = source.getY() < dest.getY() ? 1 : -1; for (wayPosition = 0; wayPosition < movesNumber; wayPosition++) { currentX += moveForX; currentY += moveForY; way[wayPosition] = new Cell(currentX, currentY); } return Arrays.copyOf(way, wayPosition); } Bishop(Cell position); Cell[] way(Cell source, Cell dest); Figure copy(Cell dest);  }### Answer:
@Test public void ifBishopGoingFromPointFourFourToPointTwoTwo() throws ImpossibleMoveException { Bishop bishop = new Bishop(new Cell(4, 4)); Cell[] result = bishop.way(new Cell(4, 4), new Cell(2, 2)); Cell[] expect = {new Cell(3, 3), new Cell(2, 2)}; assertThat(result, is(expect)); }
@Test public void ifBishopGoingFromPointFourFourToPointSixSix() throws ImpossibleMoveException { Bishop bishop = new Bishop(new Cell(4, 4)); Cell[] result = bishop.way(new Cell(4, 4), new Cell(6, 6)); Cell[] expect = {new Cell(5, 5), new Cell(6, 6)}; assertThat(result, is(expect)); }
@Test public void ifBishopGoingFromPointFourFourToPointSixTwo() throws ImpossibleMoveException { Bishop bishop = new Bishop(new Cell(4, 4)); Cell[] result = bishop.way(new Cell(4, 4), new Cell(6, 2)); Cell[] expect = {new Cell(5, 3), new Cell(6, 2)}; assertThat(result, is(expect)); }
@Test public void ifBishopGoingFromPointFourFourToPointTwoSix() throws ImpossibleMoveException { Bishop bishop = new Bishop(new Cell(4, 4)); Cell[] result = bishop.way(new Cell(4, 4), new Cell(2, 6)); Cell[] expect = {new Cell(3, 5), new Cell(2, 6)}; assertThat(result, is(expect)); }
@Test public void ifWrongWayThenReturnImeException() { Bishop bishop = new Bishop(new Cell(4, 4)); try { bishop.way(new Cell(4, 4), new Cell(5, 6)); } catch (ImpossibleMoveException ime) { assertThat("Слон так не ходит", is(ime.getMessage())); } }