Verify command merging in the dispatcher
This commit is contained in:
parent
82b576e38c
commit
4b6abf4084
1 changed files with 11 additions and 0 deletions
|
@ -13,6 +13,7 @@ import static net.minecraft.commands.builder.LiteralArgumentBuilder.literal;
|
|||
import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
|
@ -33,6 +34,16 @@ public class CommandDispatcherTest {
|
|||
verify(command).run(any(CommandContext.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndMergeCommands() throws Exception {
|
||||
subject.register(literal("base").then(literal("foo")).executes(command));
|
||||
subject.register(literal("base").then(literal("bar")).executes(command));
|
||||
|
||||
subject.execute("base foo");
|
||||
subject.execute("base bar");
|
||||
verify(command, times(2)).run(any(CommandContext.class));
|
||||
}
|
||||
|
||||
@Test(expected = UnknownCommandException.class)
|
||||
public void testExecuteUnknownCommand() throws Exception {
|
||||
subject.execute("foo");
|
||||
|
|
Loading…
Reference in a new issue