You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ActionGroupTest.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. package com.dmdirc.actions;
  23. import com.dmdirc.config.prefs.PreferencesSetting;
  24. import com.dmdirc.config.prefs.PreferencesType;
  25. import java.util.ArrayList;
  26. import java.util.List;
  27. import org.junit.Test;
  28. import static org.junit.Assert.*;
  29. public class ActionGroupTest extends junit.framework.TestCase {
  30. @Test
  31. public void testGetAuthor() {
  32. ActionGroup instance = new ActionGroup("moo");
  33. instance.setAuthor("foo");
  34. String expResult = "foo";
  35. String result = instance.getAuthor();
  36. assertEquals(expResult, result);
  37. }
  38. @Test
  39. public void testGetDescription() {
  40. ActionGroup instance = new ActionGroup("bar");
  41. instance.setDescription("Tra-la-la-la-la");
  42. String expResult = "Tra-la-la-la-la";
  43. String result = instance.getDescription();
  44. assertEquals(expResult, result);
  45. }
  46. @Test
  47. public void testGetName() {
  48. ActionGroup instance = new ActionGroup("foobar");
  49. String expResult = "foobar";
  50. String result = instance.getName();
  51. assertEquals(expResult, result);
  52. }
  53. @Test
  54. public void testGetSettings() {
  55. ActionGroup instance = new ActionGroup("foo");
  56. List<PreferencesSetting> expResult = new ArrayList<PreferencesSetting>();
  57. List<PreferencesSetting> result = instance.getSettings();
  58. assertEquals(expResult, result);
  59. result.add(new PreferencesSetting(PreferencesType.BOOLEAN, "", "", "", "", ""));
  60. assertEquals(1, instance.getSettings().size());
  61. }
  62. @Test
  63. public void testGetVersion() {
  64. ActionGroup instance = new ActionGroup("vtest");
  65. instance.setVersion(73);
  66. int expResult = 73;
  67. int result = instance.getVersion();
  68. assertEquals(expResult, result);
  69. }
  70. @Test
  71. public void testGetComponent() {
  72. ActionGroup instance = new ActionGroup("zzz");
  73. instance.setComponent(69);
  74. int expResult = 69;
  75. int result = instance.getComponent();
  76. assertEquals(expResult, result);
  77. }
  78. @Test
  79. public void testClear() {
  80. ActionGroup instance = new ActionGroup("zzz");
  81. instance.add(null);
  82. assertEquals(1, instance.size());
  83. instance.clear();
  84. assertEquals(0, instance.size());
  85. }
  86. @Test
  87. public void testRemove() {
  88. ActionGroup instance = new ActionGroup("zzz");
  89. instance.add(null);
  90. assertEquals(1, instance.size());
  91. instance.remove(null);
  92. assertEquals(0, instance.size());
  93. }
  94. @Test
  95. public void testContains() {
  96. ActionGroup instance = new ActionGroup("zzz");
  97. instance.add(null);
  98. assertTrue(instance.contains(null));
  99. instance.remove(null);
  100. assertFalse(instance.contains(null));
  101. }
  102. }