package boxpusher.tests;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import gdi.ws0809.test.SokobanTestAdapter;

import java.io.File;

import org.junit.BeforeClass;
import org.junit.Test;

import boxpusher.exceptions.LevelSyntaxIsIncorrectException;

public class WallBoundingTest {
	private static SokobanTestAdapter game = null;
	private static String levelDir = "data" + File.separator + "levelsets"
			+ File.separator + "Test WallBounding" + File.separator;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		game = new SokobanTestAdapter();
		game.setLevelDir(new File(levelDir));
	}

	@Test
	public void testFalsePositive() throws Exception {
		game.loadLevel(new File(levelDir + "level_01.txt"));
		assertTrue(game.checkWallBounding());
	}

	@Test(expected=LevelSyntaxIsIncorrectException.class)
	public void testOpenTunnel() throws Exception {
		game.loadLevel(new File(levelDir + "level_02.txt"));
		assertFalse(game.checkWallBounding());
	}
	
	@Test(expected=LevelSyntaxIsIncorrectException.class)
	public void testClosedWallButPlayerOutside() throws Exception {
		game.loadLevel(new File(levelDir + "level_03.txt"));
		assertFalse(game.checkWallBounding());
	}
	
	@Test(expected=LevelSyntaxIsIncorrectException.class)
	public void testSomeElementsInWallShadow() throws Exception {
		game.loadLevel(new File(levelDir + "level_04.txt"));
		assertFalse(game.checkWallBounding());
	}
	
	@Test(expected=LevelSyntaxIsIncorrectException.class)
	public void testAllElementsInWallShadow() throws Exception {
		game.loadLevel(new File(levelDir + "level_05.txt"));
		assertFalse(game.checkWallBounding());
	}
	
	@Test(expected=LevelSyntaxIsIncorrectException.class)
	public void testPlayerInsideButOtherElementsOutside() throws Exception {
		game.loadLevel(new File(levelDir + "level_06.txt"));
		assertFalse(game.checkWallBounding());
	}
}
