Browse Source

Unit test for issue 1849


git-svn-id: http://svn.dmdirc.com/trunk@4836 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6.3m1rc1
Chris Smith 16 years ago
parent
commit
b5d7b75ad9
1 changed files with 67 additions and 0 deletions
  1. 67
    0
      test/com/dmdirc/actions/wrappers/AliasWrapperTest.java

+ 67
- 0
test/com/dmdirc/actions/wrappers/AliasWrapperTest.java View File

@@ -0,0 +1,67 @@
1
+/*
2
+ * Copyright (c) 2006-2008 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.actions.wrappers;
24
+
25
+import com.dmdirc.actions.Action;
26
+import com.dmdirc.actions.ActionCondition;
27
+import com.dmdirc.actions.CoreActionComparison;
28
+import com.dmdirc.actions.CoreActionComponent;
29
+import com.dmdirc.actions.CoreActionType;
30
+import com.dmdirc.actions.interfaces.ActionType;
31
+
32
+import java.util.ArrayList;
33
+import java.util.List;
34
+
35
+import org.junit.Test;
36
+import static org.junit.Assert.*;
37
+
38
+public class AliasWrapperTest {
39
+
40
+    @Test
41
+    public void testNormal() {
42
+        final List<ActionCondition> conditions = new ArrayList<ActionCondition>();
43
+        conditions.add(new ActionCondition(1, CoreActionComponent.STRING_STRING,
44
+                CoreActionComparison.STRING_EQUALS, "testing123"));
45
+        final Action action = new Action("unit-test", "foo",
46
+                new ActionType[]{CoreActionType.UNKNOWN_COMMAND}, new String[0],
47
+                conditions, null);
48
+
49
+        assertTrue(AliasWrapper.getAliasWrapper().getAliases().isEmpty());
50
+        AliasWrapper.getAliasWrapper().add(action);
51
+        assertFalse(AliasWrapper.getAliasWrapper().getAliases().isEmpty());
52
+        assertEquals("/testing123", AliasWrapper.getAliasWrapper().getAliases().get(0));
53
+    }
54
+
55
+    @Test
56
+    public void testNoConditions() {
57
+        final List<ActionCondition> conditions = new ArrayList<ActionCondition>();
58
+        final Action action = new Action("unit-test", "foo",
59
+                new ActionType[]{CoreActionType.UNKNOWN_COMMAND}, new String[0],
60
+                conditions, null);
61
+        
62
+        final int size = AliasWrapper.getAliasWrapper().getAliases().size();
63
+        AliasWrapper.getAliasWrapper().add(action);
64
+        assertEquals(size, AliasWrapper.getAliasWrapper().getAliases().size());
65
+    }
66
+
67
+}

Loading…
Cancel
Save