//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")); }
//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")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void showsArgumentsAndDescriptionForSpecifiedCommand() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShowsArgumentsAndDescriptionForSpecifiedCommand() { CommandLocator commandLocator = mock(typeof(CommandLocator)); AdminCommand_Provider commandProvider = mock(typeof(AdminCommand_Provider)); when(commandProvider.Name()).thenReturn("foobar"); Arguments arguments = (new Arguments()).withDatabase(); when(commandProvider.AllArguments()).thenReturn(arguments); when(commandProvider.PossibleArguments()).thenReturn(Collections.singletonList(arguments)); when(commandProvider.Description()).thenReturn("This is a description of the foobar command."); when(commandLocator.FindProvider("foobar")).thenReturn(commandProvider); using (MemoryStream baos = new MemoryStream()) { PrintStream ps = new PrintStream(baos); HelpCommand helpCommand = new HelpCommand(new Usage("neo4j-admin", commandLocator), ps.println, commandLocator); helpCommand.Execute("foobar"); assertEquals(string.Format("usage: neo4j-admin foobar [--database=<name>]%n" + "%n" + "environment variables:%n" + " NEO4J_CONF Path to directory which contains neo4j.conf.%n" + " NEO4J_DEBUG Set to anything to enable debug output.%n" + " NEO4J_HOME Neo4j home directory.%n" + " HEAP_SIZE Set JVM maximum heap size during command execution.%n" + " Takes a number and a unit, for example 512m.%n" + "%n" + "This is a description of the foobar command.%n" + "%n" + "options:%n" + " --database=<name> Name of database. [default:" + GraphDatabaseSettings.DEFAULT_DATABASE_NAME + "]%n"), baos.ToString()); } }