inventory_mock tests #17

Merged
erns6604 merged 16 commits from inventory_mocks into main 2025-10-30 07:52:55 +01:00
2 changed files with 9 additions and 2 deletions
Showing only changes of commit a24e8777af - Show all commits

View File

@@ -16,8 +16,7 @@ public class DigAction implements Action {
}
private Miner requireMiner(Actor actor) {
if (actor instanceof JobHolder hasJob
&& hasJob.getJob() instanceof Miner miner) {
if (actor.getJob() instanceof Miner miner) {
return miner;
}
throw new IllegalStateException(actor + " cannot perform this action without being a Miner!");

View File

@@ -27,4 +27,12 @@ public class DigActionTest {
var action = new DigAction(biome);
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));
}
}