package mondocommand.dynamic;

import static org.junit.Assert.*;
import mondocommand.CallInfo;
import mondocommand.MockCommandSender;
import mondocommand.MondoCommand;
import mondocommand.MondoFailure;

import org.bukkit.ChatColor;
import org.junit.Test;

public class DynamicSubcommandsTest {

    @Test
    public void testMondoFailureWithDynamicSubcommands() {
        MondoCommand cmd = new FailingCommand();
        MockCommandSender sender = new MockCommandSender();
        cmd.onCommand(sender, null, "test", new String[] { "fail" });
        assertEquals(1, sender.messages.size());
        assertEquals(sender.messages.get(0), ChatColor.RED + "fail");
    }
    
    public static class FailingCommand extends MondoCommand {
        
        public FailingCommand() {
            this.autoRegisterFrom(this);
        }
        
        @Sub
        public void fail(CallInfo call) throws MondoFailure {
            throw new MondoFailure("fail");
        }
    }

}

@@ -388,23 +388,23 @@
 d = new 
-Failing
+Dynamic
 Command(
@@ -674,35 +674,409 @@
     
-public static class Failing
+@Test%0A    public void testWorkingDynamicSubcommand() %7B%0A        MondoCommand cmd = new DynamicCommand();%0A        MockCommandSender sender = new MockCommandSender();%0A        cmd.onCommand(sender, null, %22test%22, new String%5B%5D %7B%22success%22%7D);%0A        assertEquals(1, sender.messages.size());%0A        assertEquals(sender.messages.get(0), ChatColor.GREEN + %22success%22);%0A    %7D%0A    %0A    public static class Dynamic
 Comm
@@ -1130,15 +1130,15 @@
 lic 
-Failing
+Dynamic
 Comm
@@ -1330,21 +1330,140 @@
 ;%0A        %7D%0A
+        %0A        @Sub%0A        public void success(CallInfo call) %7B%0A            call.reply(%22%7BGREEN%7Dsuccess%22);%0A        %7D%0A
     %7D%0A%0A%7D%0A

Add another Test for working dynamically registered Subcommands, just to be safe