소스 검색

Add junitreports to .gitignore

Add unit test for /names command
tags/0.6.3m1rc1
Chris Smith 15 년 전
부모
커밋
94b5c835f1
2개의 변경된 파일79개의 추가작업 그리고 0개의 파일을 삭제
  1. 1
    0
      .gitignore
  2. 78
    0
      test/com/dmdirc/commandparser/commands/channel/NamesTest.java

+ 1
- 0
.gitignore 파일 보기

@@ -4,5 +4,6 @@
4 4
 /dist
5 5
 /nbproject/private
6 6
 /plugins
7
+/junitreports
7 8
 .svn
8 9
 *.class

+ 78
- 0
test/com/dmdirc/commandparser/commands/channel/NamesTest.java 파일 보기

@@ -0,0 +1,78 @@
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.IdentityManager;
29
+import com.dmdirc.parser.irc.ChannelInfo;
30
+import com.dmdirc.parser.irc.IRCParser;
31
+
32
+import org.junit.Before;
33
+import org.junit.BeforeClass;
34
+import org.junit.Test;
35
+import static org.mockito.Mockito.*;
36
+
37
+public class NamesTest {
38
+
39
+    private final Names command = new Names();
40
+    private ChannelInfo channelinfo;
41
+    private Channel channel;
42
+    private Server server;
43
+    private IRCParser parser;
44
+
45
+    @BeforeClass
46
+    public static void setUpClass() {
47
+        IdentityManager.load();
48
+    }
49
+
50
+    @Before
51
+    public void setUp() {
52
+        IdentityManager.load();
53
+        
54
+        parser = mock(IRCParser.class);
55
+        server = mock(Server.class);
56
+        channel = mock(Channel.class);
57
+        channelinfo = mock(ChannelInfo.class);
58
+
59
+        when(server.getParser()).thenReturn(parser);
60
+        when(channel.getChannelInfo()).thenReturn(channelinfo);
61
+        when(channelinfo.getName()).thenReturn("#chan");
62
+    }
63
+
64
+    @Test
65
+    public void testNormal() {
66
+        command.execute(null, server, channel, false, new CommandArguments("/names"));
67
+
68
+        verify(parser).sendLine("NAMES #chan");
69
+    }
70
+
71
+    @Test
72
+    public void testExternal() {
73
+        command.execute(null, server, "#chan", false, new CommandArguments("/names #chan"));
74
+
75
+        verify(parser).sendLine("NAMES #chan");
76
+    }
77
+
78
+}

Loading…
취소
저장