package peg_Game_Solution;

import static org.junit.Assert.*;
import org.junit.Test;

public class BoardTest {

	/* Note: This code assumes that your parser can handle multiple
	 * empty holes in the input file
	 */
	private static PegBoard board = new PegBoard("testBoard.txt");
	
	
	@Test
	// Test some valid jumps
	// Only testing 3 but probably want to test all 6 directions
	public void testValidJumps(){
		Hole from = board.findHole(0,2);
		Hole to = board.findHole(0,4);
		assertTrue(board.checkJump(from,to));
		
		from = board.findHole(3,1);
		to = board.findHole(1,1);
		assertTrue(board.checkJump(from,to));
		
		from = board.findHole(3,0);
		to = board.findHole(1,2);
		assertTrue(board.checkJump(from,to));
		
	}
	
	@Test
	// Test some invalid jumps
	public void testInvalidJumps(){
		
		// Test cases for holes that are not at correct distance
		Hole from = board.findHole(0,0);
		Hole to = board.findHole(1,1);
		assertFalse(board.checkJump(from,to));
		
		from = board.findHole(1,3);
		to = board.findHole(1,2);
		assertFalse(board.checkJump(from,to));
		
		from = board.findHole(0,0);
		to = board.findHole(0,4);
		assertFalse(board.checkJump(from,to));
		
		//Test case for jumping to occupied hole
		from = board.findHole(2,0);
		to = board.findHole(2,2);
		assertFalse(board.checkJump(from,to));
		
		//Test case for jumping from empty hole
		from = board.findHole(1,0);
		to = board.findHole(1,2);
		assertFalse(board.checkJump(from,to));
		
		//Test case for jumping over empty space
		from = board.findHole(1,3);
		to = board.findHole(1,1);
		assertFalse(board.checkJump(from,to));
	}
	
	@Test
	//Other interesting features of test cases
	public void otherTests(){
		
		//Assert equals
		assertEquals('a',97);
		
		//Assert array equals
		char[] first = {'a','b','c'};
		char[] second = {'a','b','c'};
		assertArrayEquals(first,second);
		
		//Assert same
		Hole m = new Hole(0, 0, false);
		Hole n = new Hole(0, 0, false);
		Hole o = n;
		assertSame(n,o);
		assertNotSame(m,n);
		
		//Assert null
		Hole h = null;
		assertNull(h);
	}
}
