/**
 * 
 */
package boxpusher.tests;

import static org.junit.Assert.*;

import org.junit.Test;

import boxpusher.exceptions.LevelSyntaxIsIncorrectException;
import boxpusher.game.Field;
import boxpusher.game.Levelparser;

/**
 * @author David Kalnischkies
 * 
 */
public class LevelParserTest {

	private static Field emptyField = new Field(false, false, false, false);
	private static Field wallField = new Field(true, false, false, false);
	private static Field boxField = new Field(false, true, false, false);
	private static Field playerField = new Field(false, false, true, false);
	private static Field goalField = new Field(false, false, false, true);

	private Field[][] fieldArray = new Field[][] {
			{ wallField, wallField, wallField, wallField },
			{ wallField, emptyField, playerField, wallField },
			{ wallField, boxField, emptyField, wallField },
			{ wallField, goalField, emptyField, wallField },
			{ wallField, wallField, wallField, wallField } };

	private String fieldString = "####\n# @#\n#$ #\n#. #\n####\n";

	/**
	 * Test method for
	 * {@link boxpusher.game.Levelparser#Field2String(boxpusher.game.Field[][])}
	 * .
	 */
	@Test
	public void testField2String() {
		assertTrue(Levelparser.Field2String(fieldArray).equals(fieldString));
	}

	/**
	 * Test method for
	 * {@link boxpusher.game.Levelparser#String2Field(java.lang.String)}.
	 * @throws LevelSyntaxIsIncorrectException 
	 */
	@Test
	public void testString2Field() throws LevelSyntaxIsIncorrectException {
		assertArrayEquals(fieldArray, Levelparser.String2Field(fieldString));
	}

}
