예제 #1
0
 private void BadUsage(AdminCommand_Provider command, IncorrectUsage e)
 {
     _outsideWorld.stdErrLine(e.Message);
     _outsideWorld.stdErrLine("");
     _usage.printUsageForCommand(command, _outsideWorld.stdErrLine);
     Failure();
 }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void printsUnknownCommandWhenUnknownCommandIsProvided()
        internal virtual void PrintsUnknownCommandWhenUnknownCommandIsProvided()
        {
            CommandLocator commandLocator = mock(typeof(CommandLocator));

            when(commandLocator.AllProviders).thenReturn(Collections.emptyList());
            when(commandLocator.FindProvider("foobar")).thenThrow(new NoSuchElementException("foobar"));

            HelpCommand helpCommand = new HelpCommand(mock(typeof(Usage)), @out, commandLocator);

            IncorrectUsage incorrectUsage = assertThrows(typeof(IncorrectUsage), () => helpCommand.execute("foobar"));

            assertThat(incorrectUsage.Message, containsString("Unknown command: foobar"));
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void printsAvailableCommandsWhenUnknownCommandIsProvided()
        internal virtual void PrintsAvailableCommandsWhenUnknownCommandIsProvided()
        {
            CommandLocator commandLocator = mock(typeof(CommandLocator));
            IList <AdminCommand_Provider> mockCommands = new IList <AdminCommand_Provider> {
                MockCommand("foo"), MockCommand("bar"), MockCommand("baz")
            };

            when(commandLocator.AllProviders).thenReturn(mockCommands);
            when(commandLocator.FindProvider("foobar")).thenThrow(new NoSuchElementException("foobar"));

            HelpCommand helpCommand = new HelpCommand(mock(typeof(Usage)), @out, commandLocator);

            IncorrectUsage incorrectUsage = assertThrows(typeof(IncorrectUsage), () => helpCommand.execute("foobar"));

            assertThat(incorrectUsage.Message, containsString("Available commands are: foo bar baz"));
        }