use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandUtilsTest method getNumber_playerTilde_zero.
@Test
void getNumber_playerTilde_zero() throws WrongUsageException {
final DummyCommandSender dummyCommandSender = new DummyCommandSender(testManager);
double result = CommandUtils.getNumber(dummyCommandSender, "~", 100);
Assertions.assertEquals(100.0, result);
}
use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandRemoveTest method command_removeMissiles.
@ParameterizedTest
@MethodSource("provideArgsToTest")
void command_removeMissiles(String[] args, boolean removeMissile) {
dummyCommandSender.position = new Vec3d(100, 20, 100);
// Spawn some sheep to act as decoys
TestUtils.sheep(testManager.getWorld(), 100, 20, 100);
TestUtils.sheep(testManager.getWorld(), 100, 30, 100);
TestUtils.sheep(testManager.getWorld(), 100, 40, 100);
TestUtils.missile(testManager.getWorld(), 100, 10, 100);
TestUtils.missile(testManager.getWorld(), 100, 20, 100);
// Validate start condition
Assertions.assertEquals(3, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntitySheep).count(), "Should start with 3 sheep");
Assertions.assertEquals(2, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntityMissile).count(), "Should start with 2 missiles");
// Trigger command
Assertions.assertDoesNotThrow(() -> command.handleCommand(testManager.getServer(), dummyCommandSender, args));
// Validate output
Assertions.assertEquals(1, dummyCommandSender.messages.size(), "Should have 1 chat message");
Assertions.assertEquals(CommandRemove.TRANSLATION_REMOVE, dummyCommandSender.pollLastMessage(), "Should get translation");
// Should still have 3 sheep
Assertions.assertEquals(3, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntitySheep).count(), "Should end with 3 sheep");
Assertions.assertEquals(removeMissile ? 0 : 2, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntityMissile).filter(Entity::isEntityAlive).count(), "Should end with 0 missiles");
}
use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandEntryPointTest method getTabCompletions_zero.
@Test
void getTabCompletions_zero() {
final DummyCommandSender dummyCommandSender = new DummyCommandSender(testManager);
List<String> output = commandHandler.getTabCompletions(testManager.getServer(), dummyCommandSender, new String[0], null);
Assertions.assertEquals(0, output.size());
}
use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandEntryPointTest method getTabCompletions_help.
@Test
void getTabCompletions_help() {
final DummyCommandSender dummyCommandSender = new DummyCommandSender(testManager);
List<String> output = commandHandler.getTabCompletions(testManager.getServer(), dummyCommandSender, new String[] { "h" }, null);
Assertions.assertEquals(1, output.size());
Assertions.assertEquals(output.get(0), "help");
}
use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandEntryPointTest method execute_nothing.
@Test
void execute_nothing() throws CommandException {
final DummyCommandSender dummyCommandSender = new DummyCommandSender(testManager);
// Run command
commandHandler.execute(testManager.getServer(), dummyCommandSender, new String[0]);
Assertions.assertEquals(1, dummyCommandSender.messages.size());
Assertions.assertEquals("/icbm help", dummyCommandSender.messages.poll().getUnformattedText());
}
Aggregations