Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

HelpTest.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2006-2013 DMDirc Developers
  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.commandparser.commands;
  23. import com.dmdirc.interfaces.LifecycleController;
  24. import com.dmdirc.ServerManager;
  25. import com.dmdirc.commandparser.CommandInfo;
  26. import com.dmdirc.commandparser.CommandLoader;
  27. import com.dmdirc.commandparser.CommandManager;
  28. import com.dmdirc.commandparser.CommandType;
  29. import com.dmdirc.config.IdentityManager;
  30. import com.dmdirc.config.InvalidIdentityFileException;
  31. import com.dmdirc.interfaces.ActionController;
  32. import com.dmdirc.plugins.PluginManager;
  33. import com.dmdirc.ui.messages.ColourManager;
  34. import java.util.LinkedList;
  35. import java.util.List;
  36. import org.junit.Test;
  37. import org.junit.runner.RunWith;
  38. import org.junit.runners.Parameterized;
  39. import static org.mockito.Mockito.*;
  40. import static org.junit.Assert.*;
  41. @RunWith(Parameterized.class)
  42. public class HelpTest {
  43. private CommandInfo info;
  44. public HelpTest(final CommandInfo info) {
  45. this.info = info;
  46. }
  47. @Test
  48. public void testHelp() {
  49. assertTrue("Command's help output should start with its name ("
  50. + info.getName() + ")", info.getHelp().startsWith(info.getName()));
  51. }
  52. @Parameterized.Parameters
  53. public static List<Object[]> data() throws InvalidIdentityFileException {
  54. final List<Object[]> res = new LinkedList<>();
  55. final ServerManager serverManager = mock(ServerManager.class);
  56. final CommandManager commandManager = new CommandManager(serverManager);
  57. new CommandLoader(
  58. mock(LifecycleController.class),
  59. serverManager,
  60. mock(PluginManager.class),
  61. mock(IdentityManager.class),
  62. mock(ActionController.class),
  63. mock(ColourManager.class)).loadCommands(commandManager);
  64. for (CommandType type : CommandType.values()) {
  65. for (CommandInfo command : commandManager.getCommands(type).keySet()) {
  66. res.add(new Object[]{command});
  67. }
  68. }
  69. return res;
  70. }
  71. }