//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldPrintUsageForACommand() internal virtual void ShouldPrintUsageForACommand() { // given AdminCommand_Provider commandProvider = MockCommand("bam", "A summary", AdminCommandSection.General()); AdminCommand_Provider[] commands = new AdminCommand_Provider[] { commandProvider }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Usage usage = new Usage("neo4j-admin", new CannedLocator(commands)); Usage usage = new Usage("neo4j-admin", new CannedLocator(commands)); // when usage.PrintUsageForCommand(commandProvider, @out); // then InOrder ordered = inOrder(@out); ordered.verify(@out).accept("usage: neo4j-admin bam "); ordered.verify(@out).accept(""); ordered.verify(@out).accept("environment variables:"); ordered.verify(@out).accept(" NEO4J_CONF Path to directory which contains neo4j.conf."); ordered.verify(@out).accept(" NEO4J_DEBUG Set to anything to enable debug output."); ordered.verify(@out).accept(" NEO4J_HOME Neo4j home directory."); ordered.verify(@out).accept(" HEAP_SIZE Set JVM maximum heap size during command execution."); ordered.verify(@out).accept(" Takes a number and a unit, for example 512m."); ordered.verify(@out).accept(""); ordered.verify(@out).accept("description"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldPrintUsageWithConfiguration() internal virtual void ShouldPrintUsageWithConfiguration() { AdminCommand_Provider[] commands = new AdminCommand_Provider[] { MockCommand("bam", "A summary", AdminCommandSection.General()) }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Usage usage = new Usage("neo4j-admin", new CannedLocator(commands)); Usage usage = new Usage("neo4j-admin", new CannedLocator(commands)); usage.Print(@out); InOrder ordered = inOrder(@out); ordered.verify(@out).accept("usage: neo4j-admin <command>"); ordered.verify(@out).accept(""); ordered.verify(@out).accept("Manage your Neo4j instance."); ordered.verify(@out).accept(""); ordered.verify(@out).accept("environment variables:"); ordered.verify(@out).accept(" NEO4J_CONF Path to directory which contains neo4j.conf."); ordered.verify(@out).accept(" NEO4J_DEBUG Set to anything to enable debug output."); ordered.verify(@out).accept(" NEO4J_HOME Neo4j home directory."); ordered.verify(@out).accept(" HEAP_SIZE Set JVM maximum heap size during command execution."); ordered.verify(@out).accept(" Takes a number and a unit, for example 512m."); ordered.verify(@out).accept(""); ordered.verify(@out).accept("available commands:"); ordered.verify(@out).accept("General"); ordered.verify(@out).accept(" bam"); ordered.verify(@out).accept(" A summary"); ordered.verify(@out).accept(""); ordered.verify(@out).accept("Use neo4j-admin help <command> for more details."); ordered.verifyNoMoreInteractions(); }
private void BadUsage(AdminCommand_Provider command, IncorrectUsage e) { _outsideWorld.stdErrLine(e.Message); _outsideWorld.stdErrLine(""); _usage.printUsageForCommand(command, _outsideWorld.stdErrLine); Failure(); }
private static AdminCommand_Provider MockCommand(string name) { AdminCommand_Provider commandProvider = mock(typeof(AdminCommand_Provider)); when(commandProvider.Name()).thenReturn(name); when(commandProvider.CommandSection()).thenReturn(AdminCommandSection.General()); return(commandProvider); }
public virtual void PrintUsageForCommand(AdminCommand_Provider command, System.Action <string> output) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CommandUsage commandUsage = new CommandUsage(command, scriptName); CommandUsage commandUsage = new CommandUsage(command, _scriptName); commandUsage.PrintDetailed(output); }
private static AdminCommand_Provider MockCommand(string name, string summary, AdminCommandSection section) { AdminCommand_Provider commandProvider = mock(typeof(AdminCommand_Provider)); when(commandProvider.Name()).thenReturn(name); when(commandProvider.Summary()).thenReturn(summary); when(commandProvider.AllArguments()).thenReturn(Arguments.NO_ARGS); when(commandProvider.PossibleArguments()).thenReturn(Collections.singletonList(Arguments.NO_ARGS)); when(commandProvider.Description()).thenReturn("description"); when(commandProvider.CommandSection()).thenReturn(section); return(commandProvider); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void execute(String... args) throws IncorrectUsage public override void Execute(params string[] args) { if (args.Length > 0) { try { AdminCommand_Provider commandProvider = this._locator.findProvider(args[0]); _usage.printUsageForCommand(commandProvider, _output); } catch (NoSuchElementException) { StringBuilder validCommands = new StringBuilder(); _locator.AllProviders.forEach(commandProvider => validCommands.Append(commandProvider.name()).Append(" ")); throw new IncorrectUsage(format("Unknown command: %s. Available commands are: %s\n", args[0], validCommands)); } } else { _usage.print(_output); } }
//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()); } }
internal CommandUsage(AdminCommand_Provider command, string scriptName) { this._command = command; this._scriptName = scriptName; }