Procházet zdrojové kódy

Couple of test additions/improvements

Change-Id: Id0c8eedd2654afd9590cc2520dcafa889b053e16
Reviewed-on: http://gerrit.dmdirc.com/3387
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith před 10 roky
rodič
revize
ff9c4160d0

+ 5
- 4
test/com/dmdirc/commandparser/commands/channel/ModeTest.java Zobrazit soubor

@@ -38,7 +38,8 @@ import org.junit.runner.RunWith;
38 38
 import org.mockito.Mock;
39 39
 import org.mockito.runners.MockitoJUnitRunner;
40 40
 
41
-import static org.mockito.Mockito.*;
41
+import static org.mockito.Mockito.verify;
42
+import static org.mockito.Mockito.when;
42 43
 
43 44
 @RunWith(MockitoJUnitRunner.class)
44 45
 public class ModeTest {
@@ -80,8 +81,8 @@ public class ModeTest {
80 81
 
81 82
     @Test
82 83
     public void testExternalWithArgs() {
83
-        command.execute(origin, new CommandArguments(controller, "/mode +hello -bye"),
84
-                new ChannelCommandContext(null, Mode.INFO, channel));
84
+        command.execute(origin, server, "#chan", false,
85
+                new CommandArguments(controller, "/mode +hello -bye"));
85 86
 
86 87
         verify(parser).sendRawMessage("MODE #chan +hello -bye");
87 88
     }
@@ -89,7 +90,7 @@ public class ModeTest {
89 90
     @Test
90 91
     public void testExternalWithoutArgs() {
91 92
         command.execute(origin, server, "#chan", false,
92
-                new CommandArguments(controller,"/mode"));
93
+                new CommandArguments(controller, "/mode"));
93 94
 
94 95
         verify(parser).sendRawMessage("MODE #chan");
95 96
     }

+ 23
- 0
test/com/dmdirc/commandparser/parsers/CommandParserTest.java Zobrazit soubor

@@ -233,4 +233,27 @@ public class CommandParserTest {
233 233
         assertEquals("", channelCommandParser.commandArgs.getArgumentsAsString());
234 234
     }
235 235
 
236
+    @Test
237
+    public void testParseUnregisterCommand() {
238
+        commandParser.unregisterCommand(commandInfo);
239
+        commandParser.parseCommand(null, "/command test 123");
240
+
241
+        assertNull(commandParser.nonCommandLine);
242
+        assertEquals("command", commandParser.invalidCommand);
243
+        assertNull(commandParser.executedCommand);
244
+        assertFalse(commandParser.wasSilent);
245
+    }
246
+
247
+    @Test
248
+    public void testGetCommands() {
249
+        assertEquals(2, commandParser.getCommands().size());
250
+        assertTrue(commandParser.getCommands().containsKey("command"));
251
+        assertTrue(commandParser.getCommands().containsKey("channel"));
252
+
253
+        commandParser.unregisterCommand(commandInfo);
254
+        assertEquals(1, commandParser.getCommands().size());
255
+        assertFalse(commandParser.getCommands().containsKey("command"));
256
+        assertTrue(commandParser.getCommands().containsKey("channel"));
257
+    }
258
+
236 259
 }

Načítá se…
Zrušit
Uložit