Skip to content
Snippets Groups Projects
PlayerTest.java 1.24 KiB
package inf112.skeleton.app;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.*;

public class PlayerTest {
	
	@Test
	void MoveRightTest(){
		Player player = new Player();
		player.canMoveDown = false;
		player.canMoveUp = false;
		player.canMoveLeft = false;
		player.canMoveRight = true;
		player.move_right = true;
		int x2 = player.x;
		player.Move();
		assertEquals(player.x, player.speed+x2);
	}
	
	@Test
	void MoveLeftTest(){
		Player player = new Player();
		player.canMoveDown = false;
		player.canMoveUp = false;
		player.canMoveLeft = true;
		player.canMoveRight = false;
		player.move_left = true;
		int x2 = player.x;
		player.Move();
		assertEquals(player.x, x2-player.speed);
	}
	
	@Test
	void MoveUpTest(){
		Player player = new Player();
		player.canMoveDown = false;
		player.canMoveUp = true;
		player.canMoveLeft = false;
		player.canMoveRight = false;
		player.jump = true;
		int y2 = player.y;
		player.Move();
		assertEquals(player.y, y2-6);
	}
	
	@Test
	void MoveDownTest(){
		Player player = new Player();
		player.canMoveDown = true;
		player.canMoveUp = false;
		player.canMoveLeft = false;
		player.canMoveRight = false;
		int y2 = player.y;
		player.Move();
		assertEquals(player.y, y2+player.gravity);
	}
	
}