Order tests

This commit is contained in:
Norbi Peti 2024-03-16 00:35:52 +01:00
parent 702655cf9f
commit a39539ea6e

View file

@ -32,6 +32,15 @@ class Command2MCTest {
} }
} }
@Test
@Order(1)
fun testUnregisterCommands() {
// First test unregistering the builtin command
// FIXME should have the init code separate of the plugin init code
ButtonPlugin.command2MC.unregisterCommands(MainPlugin.instance)
assert(ButtonPlugin.command2MC.commandNodes.isEmpty())
}
@Test @Test
@Order(2) @Order(2)
fun testRegisterCommand() { fun testRegisterCommand() {
@ -56,31 +65,6 @@ class Command2MCTest {
assertEquals("There are no subcommands defined in the command class TestEmptyCommand!", assertFails { TestEmptyCommand.register() }.message) assertEquals("There are no subcommands defined in the command class TestEmptyCommand!", assertFails { TestEmptyCommand.register() }.message)
} }
@Test
@Order(5)
fun testHasPermission() {
}
@Test
@Order(4)
fun testAddParamConverter() {
TestParamConverterCommand.register()
ButtonPlugin.command2MC.addParamConverter(TestConvertedParameter::class.java, {
if (it == "test") null
else TestConvertedParameter(it)
}, "Failed to convert test param!") { arrayOf("test1", "test2").asIterable() }
val sender = createSender()
sender.assertCommand("/testparamconverter hmm", TestParamConverterCommand, "hmm")
sender.assertCommandUserError("/testparamconverter test", "§cError: §cFailed to convert test param!")
}
@Test
@Order(1)
fun testUnregisterCommands() {
ButtonPlugin.command2MC.unregisterCommands(MainPlugin.instance) // FIXME should have the init code separate of the plugin init code
assert(ButtonPlugin.command2MC.commandNodes.isEmpty())
}
@Test @Test
@Order(3) @Order(3)
fun testHandleCommand() { fun testHandleCommand() {
@ -110,6 +94,24 @@ class Command2MCTest {
) )
} }
@Test
@Order(4)
fun testAddParamConverter() {
TestParamConverterCommand.register()
ButtonPlugin.command2MC.addParamConverter(TestConvertedParameter::class.java, {
if (it == "test") null
else TestConvertedParameter(it)
}, "Failed to convert test param!") { arrayOf("test1", "test2").asIterable() }
val sender = createSender()
sender.assertCommand("/testparamconverter hmm", TestParamConverterCommand, "hmm")
sender.assertCommandUserError("/testparamconverter test", "§cError: §cFailed to convert test param!")
}
@Test
@Order(5)
fun testHasPermission() {
}
private fun createSender(): TestCommand2MCSender { private fun createSender(): TestCommand2MCSender {
val user = ChromaGamerBase.getUser(UUID.randomUUID().toString(), TBMCPlayer::class.java) val user = ChromaGamerBase.getUser(UUID.randomUUID().toString(), TBMCPlayer::class.java)
user.playerName = "TestPlayer" user.playerName = "TestPlayer"