import static org.junit.Assert.*;
import org.junit.Test;

/**************************************************************************
 * This class tests the CharMatrix class methods
 * 
 * @author Nancy Harris and ...
 * @version Jan 23/2014
 *************************************************************************/
public class CharMatrixTest
{

    /**************************************************************************
     * Test the constructor and toString methods
     **************************************************************************/
    @Test
    public void testGeneral()
    {
        CharMatrix board;
        String expected;
        String actual;

        board = new CharMatrix(3, 4, '*');
        expected = "[****]\n[****]\n[****]\n";
        actual = board.toString();
        assertEquals("Check your constructor or toString methods", expected, actual);
    }

    /**************************************************************************
     * This method tests the clearRect method
     *************************************************************************/
    @Test
    public void testclearRect()
    {
        CharMatrix board;
        String expected;
        String actual;

        // full rectangle test
        board = new CharMatrix(3, 4, '*');
        board.clearRect(0, 0, 2, 3);
        expected = "[    ]\n[    ]\n[    ]\n";
        actual = board.toString();
        assertEquals("Check clear rectangle - full test", expected, actual);

        board.fillRect(0, 0, 2, 3, '*');
        board.clearRect(0, 0, 1, 1);
        expected = "[  **]\n[  **]\n[****]\n";
        actual = board.toString();
        assertEquals("Check clear rectangle - 0-1 test", expected, actual);

    }

    /**************************************************************************
     * This method tests the countInCol method
     *************************************************************************/
    @Test
    public void testcountInCol()
    {
        CharMatrix board;
        int expected;
        int actual;

        board = new CharMatrix(3, 4, '*');
        board.clearRect(0, 0, 1, 1);
        assertEquals("Setup in testcountInCol", "[  **]\n[  **]\n[****]\n", board.toString());

        expected = 1;
        actual = board.countInCol(0);
        assertEquals("Count in column 0", expected, actual);

        expected = 3;
        actual = board.countInCol(2);
        assertEquals("Count in column 2", expected, actual);
    }

    /**************************************************************************
     * This method tests the countInRow method
     *************************************************************************/
    @Test
    public void testcountInRow()
    {
        CharMatrix board;
        int expected;
        int actual;

        board = new CharMatrix(3, 4, '*');
        board.clearRect(0, 0, 1, 1);
        assertEquals("Setup in testcountInRow", "[  **]\n[  **]\n[****]\n", board.toString());

        expected = 2;
        actual = board.countInRow(0);
        assertEquals("Count in row 0", expected, actual);

        expected = 4;
        actual = board.countInRow(2);
        assertEquals("Count in row 2", expected, actual);
    }

    /**************************************************************************
     * This method tests the fillRect method
     *************************************************************************/
    @Test
    public void testfillRect()
    {
        String expected;
        String actual;
        CharMatrix board;

        board = new CharMatrix(3, 4, '*');
        board.fillRect(0, 0, 2, 3, '&');
        expected = "[&&&&]\n[&&&&]\n[&&&&]\n";
        actual = board.toString();
        assertEquals("Problem in fillRect full", expected, actual);

        board.fillRect(0, 0, 1, 1, '=');
        expected = "[==&&]\n[==&&]\n[&&&&]\n";
        actual = board.toString();
        assertEquals("Problem in fillRect partial", expected, actual);
    }

    /**************************************************************************
     * This method tests the isEmpty method
     *************************************************************************/
    @Test
    public void testisEmpty()
    {
        boolean expected;
        boolean actual;
        CharMatrix board;

        board = new CharMatrix(3, 4, '*');
        board.clearRect(0, 0, 1, 1);
        assertEquals("Setup in testisEmpty", "[  **]\n[  **]\n[****]\n", board.toString());

        expected = true;
        actual = board.isEmpty(1, 1);
        assertEquals("Check is empty 1, 1", expected, actual);

        expected = false;
        actual = board.isEmpty(2, 3);
        assertEquals("Check isEmpty 2, 3", expected, actual);
    }

    /**************************************************************************
     * This method tests the numCols method
     *************************************************************************/
    @Test
    public void testnumCols()
    {
        // ================================================
        // This one is for you to write. Notice the pattern
        // of the tests...create a matrix of given size,
        // then test the method, in this case numCols.
        // =================================================
        fail("Not yet implemented");
    }

    /**************************************************************************
     * This method tests the numRows method
     *************************************************************************/
    @Test
    public void testnumRows()
    {
        // ================================================
        // This one is for you to write. Notice the pattern
        // of the tests...create a matrix of given size,
        // then test the method, in this case numRows.
        // =================================================
        fail("Not yet implemented");
    }

}
