inventory_mock tests #17
@@ -5,12 +5,10 @@ import Entity.Position;
|
||||
import Inventory.Inventory;
|
||||
import Job.Miner;
|
||||
import Entity.Player;
|
||||
import Terrain.Biome;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import Job.Wizard;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
@@ -20,6 +18,15 @@ class PlayerTest {
|
||||
return new Player("abc");
|
||||
}
|
||||
|
||||
@Test
|
||||
void player_can_be_created_with_job_and_inventory() {
|
||||
var job = mock(Miner.class);
|
||||
var inventory = mock(Inventory.class);
|
||||
var player = new Player("abc", job, inventory);
|
||||
assertThat(player, instanceOf(Player.class));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void is_dead_if_health_is_zero() {
|
||||
var p = defaultPlayer();
|
||||
@@ -64,12 +71,36 @@ class PlayerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void can_not_walk_two_spaces() {
|
||||
public void can_not_walk_two_spaces_y() {
|
||||
var p = defaultPlayer();
|
||||
p.moveTo(new Position(1,2));
|
||||
assertEquals(new Position(0,0), p.getPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void can_not_walk_two_spaces_x() {
|
||||
var p = defaultPlayer();
|
||||
p.moveTo(new Position(2,1));
|
||||
assertEquals(new Position(0,0), p.getPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
void can_not_walk_two_spaces_y_negative() {
|
||||
var p = defaultPlayer();
|
||||
p.setPosition(new Position(3,3));
|
||||
p.moveTo(new Position(1,3));
|
||||
assertEquals(new Position(3,3), p.getPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
void can_not_walk_two_spaces_x_negative() {
|
||||
var p = defaultPlayer();
|
||||
p.setPosition(new Position(3,3));
|
||||
p.moveTo(new Position(3,1));
|
||||
assertEquals(new Position(3,3), p.getPosition());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void can_change_job() {
|
||||
var p = defaultPlayer();
|
||||
|
||||
Reference in New Issue
Block a user