/*
 * Created on Nov 20, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package WheelOfFortune.game;

import junit.framework.TestCase;
import WheelOfFortune.storage.Puzzle;

/**
 * @author caih
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class BoardTest extends TestCase {
	public void testSolvePuzzle()
	{
		Board b1 = new Board(new Puzzle("Hello World", "phrase"));
		assertTrue(b1.solvePuzzle("Hello World"));
		assertTrue(b1.solvePuzzle("hello world"));
		assertTrue(b1.solvePuzzle("HELLO WORLD"));		
	}
	public void testDisplay()
	{
		Board b2 = new Board(new Puzzle("Hello World", "phrase"));
		Board b3 = new Board(new Puzzle("Well well well", "phrase"));
		assertEquals(b2.display(),"***** *****");
		assertTrue(b2.display()!=null);
		b2.guessLetter('h');
		assertEquals(b2.display(),"H**** *****");
		b2.guessLetter('l');
		assertEquals(b2.display(),"H*LL* ***L*");
		b3.guessLetter('w');
		assertEquals(b3.display(), "W*** W*** W***");
		String temp = "Test String";
		Board b4 = new Board(new Puzzle(temp, "phrase"));
		b4.guessLetter('t');
		String result= "";
		for(int i = 0; i < temp.length(); i++)
		{
			if(temp.toUpperCase().charAt(i) != 'T'
				&& temp.toUpperCase().charAt(i) != ' ')
				result += "*";
			else
				result += temp.toUpperCase().charAt(i);
		}
		assertEquals(b4.display(), result);
	}
}
