inventory_mock tests #17
@@ -16,8 +16,7 @@ public class DigAction implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Miner requireMiner(Actor actor) {
|
private Miner requireMiner(Actor actor) {
|
||||||
if (actor instanceof JobHolder hasJob
|
if (actor.getJob() instanceof Miner miner) {
|
||||||
&& hasJob.getJob() instanceof Miner miner) {
|
|
||||||
return miner;
|
return miner;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException(actor + " cannot perform this action without being a Miner!");
|
throw new IllegalStateException(actor + " cannot perform this action without being a Miner!");
|
||||||
|
|||||||
@@ -27,4 +27,12 @@ public class DigActionTest {
|
|||||||
var action = new DigAction(biome);
|
var action = new DigAction(biome);
|
||||||
assertThrows(IllegalStateException.class, () -> action.execute(player));
|
assertThrows(IllegalStateException.class, () -> action.execute(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void digging_when_not_have_job_throws_error() {
|
||||||
|
var player = mock(Player.class);
|
||||||
|
var biome = mock(Biome.class);
|
||||||
|
var action = new DigAction(biome);
|
||||||
|
assertThrows(IllegalStateException.class, () -> action.execute(player));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user