Procházet zdrojové kódy

/part unit test

tags/0.6.3m1rc1
Chris Smith před 15 roky
rodič
revize
a3805efd4f

+ 1
- 1
src/com/dmdirc/FrameContainer.java Zobrazit soubor

@@ -91,7 +91,7 @@ public abstract class FrameContainer {
91 91
     /**
92 92
      * Closes this container (and it's associated frame).
93 93
      */
94
-    public final void close() {
94
+    public void close() {
95 95
         if (getFrame() == null) {
96 96
             throw new IllegalStateException("No frame associated with this container!");
97 97
         } else {

+ 79
- 0
test/com/dmdirc/commandparser/commands/channel/PartTest.java Zobrazit soubor

@@ -0,0 +1,79 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.commands.channel;
24
+
25
+import com.dmdirc.Channel;
26
+import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
28
+import com.dmdirc.config.ConfigManager;
29
+import com.dmdirc.config.IdentityManager;
30
+import com.dmdirc.parser.irc.ChannelInfo;
31
+import com.dmdirc.parser.irc.IRCParser;
32
+import com.dmdirc.ui.interfaces.InputWindow;
33
+
34
+import org.junit.Before;
35
+import org.junit.BeforeClass;
36
+import org.junit.Test;
37
+import static org.mockito.Mockito.*;
38
+
39
+public class PartTest {
40
+
41
+    private final Part command = new Part();
42
+    private Channel channel;
43
+    private InputWindow origin;
44
+    private ConfigManager manager;
45
+
46
+    @BeforeClass
47
+    public static void setUpClass() {
48
+        IdentityManager.load();
49
+    }
50
+
51
+    @Before
52
+    public void setUp() {
53
+        IdentityManager.load();
54
+        
55
+        channel = mock(Channel.class);
56
+        origin = mock(InputWindow.class);
57
+        manager = mock(ConfigManager.class);
58
+        
59
+        when(origin.getConfigManager()).thenReturn(manager);
60
+        when(manager.getOption("general", "partmessage")).thenReturn("config part message");
61
+    }
62
+
63
+    @Test
64
+    public void testWithoutArgs() {
65
+        command.execute(origin, null, channel, false, new CommandArguments("/part"));
66
+
67
+        verify(channel).part("config part message");
68
+        verify(channel).close();
69
+    }
70
+
71
+    @Test
72
+    public void testWithArgs() {
73
+        command.execute(origin, null, channel, false, new CommandArguments("/part custom part"));
74
+
75
+        verify(channel).part("custom part");
76
+        verify(channel).close();
77
+    }
78
+
79
+}

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