package ru.pravvich.figures;

import org.junit.Test;
import ru.pravvich.Board;
import ru.pravvich.Cell;
import ru.pravvich.ImposableMoveException;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class OfficerTest {

    @Test
    public void whenRoadGoodThenReturnCellArrWithRoad() throws ImposableMoveException {
        for (int i = 0; i != 8 ; i++) {
            Board.desc[i][i] = new Place(new Cell(i,i),"");
        }
        Board.desc[4][4] = new Officer(new Cell(4,4),"white");
        Cell[] result = Board.desc[4][4].move(new Cell(7,7));
        Cell[] check = new Cell[2];
        check[0] = new Cell(5,5);
        check[1] = new Cell(6,6);
        assertThat(check[0].getX(), is(result[0].getX()));
        assertThat(check[0].getY(), is(result[0].getY()));
        assertThat(check[1].getX(), is(result[1].getX()));
        assertThat(check[1].getY(), is(result[1].getY()));
        assertThat(check.length, is(result.length));
    }

    @Test
    public void whenRoadBadThenThrowImposableMoveException() throws ImposableMoveException {
        for (int i = 0; i != 8 ; i++) {
            Board.desc[i][i] = new Place(new Cell(i,i),"");
        }
        Board.desc[4][4] = new Officer(new Cell(4,4),"white");
        Board.desc[6][6] = new Officer(new Cell(6,6),"white");
        Cell[] result = Board.desc[4][4].move(new Cell(7,7));
        assertThat(result.length, is(0));
    }
}
@@ -140,16 +140,17 @@
 eption;%0A
+%0A
 import s
@@ -372,33 +372,32 @@
 nt i = 0; i != 8
- 
 ; i++) %7B%0A       
@@ -433,35 +433,37 @@
 lace(new Cell(i,
+ 
 i),
+ 
 %22%22);%0A        %7D%0A 
@@ -503,35 +503,37 @@
 icer(new Cell(4,
+ 
 4),
+ 
 %22white%22);%0A      
@@ -575,32 +575,33 @@
 move(new Cell(7,
+ 
 7));%0A        Cel
@@ -655,16 +655,17 @@
  Cell(5,
+ 
 5);%0A    
@@ -690,16 +690,17 @@
  Cell(6,
+ 
 6);%0A    
@@ -1124,17 +1124,16 @@
 ; i != 8
- 
 ; i++) %7B
@@ -1185,19 +1185,21 @@
  Cell(i,
+ 
 i),
+ 
 %22%22);%0A   
@@ -1255,19 +1255,21 @@
  Cell(4,
+ 
 4),
+ 
 %22white%22)
@@ -1324,11 +1324,13 @@
 l(6,
+ 
 6),
+ 
 %22whi
@@ -1392,16 +1392,17 @@
  Cell(7,
+ 
 7));%0A   

test for officer