Browse Source

Added some small unit tests

git-svn-id: http://svn.dmdirc.com/trunk@1442 00569f92-eb28-0410-84fd-f71c24880f
tags/0.4
Chris Smith 17 years ago
parent
commit
9ea50d1f96

+ 50
- 0
test/com/dmdirc/actions/ActionManagerTest.java View File

@@ -0,0 +1,50 @@
1
+/*
2
+ * ActionManagerTest.java
3
+ * JUnit 4.x based test
4
+ *
5
+ * Created on 05 June 2007, 22:47
6
+ */
7
+
8
+package com.dmdirc.actions;
9
+
10
+import org.junit.AfterClass;
11
+import org.junit.Before;
12
+import org.junit.BeforeClass;
13
+import org.junit.Test;
14
+import static org.junit.Assert.*;
15
+
16
+/**
17
+ *
18
+ * @author chris
19
+ */
20
+public class ActionManagerTest {
21
+    
22
+    public ActionManagerTest() {
23
+    }
24
+
25
+    @BeforeClass
26
+    public static void setUpClass() throws Exception {
27
+        ActionManager.init();
28
+    }
29
+
30
+    @AfterClass
31
+    public static void tearDownClass() throws Exception {
32
+    }
33
+
34
+    @Before
35
+    public void setUp() throws Exception {
36
+    }
37
+
38
+    @Test
39
+    public void substituteVars() {
40
+        final Object[] args = new Object[]{
41
+            "foo", "someCommand", new String[]{"a", "b", "c", "d"}
42
+        };
43
+        
44
+        final String subject = "Blah blah ${1.STRING_STRING} $1 $2 $3-$4- $1-";
45
+        final String expected = "Blah blah someCommand a b c dd a b c d";
46
+        
47
+        assertEquals(expected, ActionManager.substituteVars(subject, args));
48
+    }
49
+    
50
+}

+ 51
- 0
test/com/dmdirc/actions/CoreActionMetaTypeTest.java View File

@@ -0,0 +1,51 @@
1
+/*
2
+ * CoreActionMetaTypeTest.java
3
+ * JUnit 4.x based test
4
+ *
5
+ * Created on 05 June 2007, 22:55
6
+ */
7
+
8
+package com.dmdirc.actions;
9
+
10
+import org.junit.AfterClass;
11
+import org.junit.Before;
12
+import org.junit.BeforeClass;
13
+import org.junit.Test;
14
+import static org.junit.Assert.*;
15
+
16
+/**
17
+ *
18
+ * @author chris
19
+ */
20
+public class CoreActionMetaTypeTest {
21
+    
22
+    public CoreActionMetaTypeTest() {
23
+    }
24
+
25
+    @BeforeClass
26
+    public static void setUpClass() throws Exception {
27
+    }
28
+
29
+    @AfterClass
30
+    public static void tearDownClass() throws Exception {
31
+    }
32
+
33
+    @Before
34
+    public void setUp() throws Exception {
35
+    }
36
+
37
+    @Test
38
+    public void checkArgTypeSize() {
39
+        for (CoreActionMetaType type : CoreActionMetaType.values()) {
40
+            assertEquals(type.getArity(), type.getArgTypes().length);
41
+        }
42
+    }
43
+    
44
+    @Test
45
+    public void checkArgNameSize() {
46
+        for (CoreActionMetaType type : CoreActionMetaType.values()) {
47
+            assertEquals(type.getArity(), type.getArgNames().length);
48
+        }
49
+    }    
50
+    
51
+}

+ 62
- 0
test/com/dmdirc/updater/UpdateTest.java View File

@@ -0,0 +1,62 @@
1
+/*
2
+ * UpdateTest.java
3
+ * JUnit 4.x based test
4
+ *
5
+ * Created on 05 June 2007, 22:59
6
+ */
7
+
8
+package com.dmdirc.updater;
9
+
10
+import org.junit.AfterClass;
11
+import org.junit.Before;
12
+import org.junit.BeforeClass;
13
+import org.junit.Test;
14
+import static org.junit.Assert.*;
15
+
16
+/**
17
+ *
18
+ * @author chris
19
+ */
20
+public class UpdateTest {
21
+    
22
+    private final String subject = "outofdate component rversion lversion url";
23
+    
24
+    private Update update;
25
+    
26
+    public UpdateTest() {
27
+    }
28
+
29
+    @BeforeClass
30
+    public static void setUpClass() throws Exception {
31
+    }
32
+
33
+    @AfterClass
34
+    public static void tearDownClass() throws Exception {
35
+    }
36
+
37
+    @Before
38
+    public void setUp() throws Exception {
39
+        update = new Update(subject);
40
+    }
41
+
42
+    @Test
43
+    public void getComponent() {
44
+        assertEquals("component", update.getComponent());
45
+    }
46
+
47
+    @Test
48
+    public void getLocalVersion() {
49
+        assertEquals("lversion", update.getLocalVersion());
50
+    }
51
+
52
+    @Test
53
+    public void getRemoteVersion() {
54
+        assertEquals("rversion", update.getRemoteVersion());
55
+    }
56
+
57
+    @Test
58
+    public void getUrl() {
59
+        assertEquals("url", update.getUrl());
60
+    }
61
+    
62
+}

Loading…
Cancel
Save