public void CommandLineHelpCommandShouldUseOrder() { var commandRepository = Substitute.For <ICommandRepository>(); commandRepository.GetCommandsInfo() .Returns(new List <CommandInfo>() { new CommandInfo() { Name = "command1", Description = "The first command.", Order = 2 }, new CommandInfo() { Name = "command2", Order = 1 }, }); var memoryOutput = new MemoryOutput(); var commandLineHelpCommand = new CommandLineHelpCommand(commandRepository, memoryOutput); commandLineHelpCommand.Execute(); var command1position = memoryOutput.Content.IndexOf(memoryOutput.Content.First(l => l.Contains("command1"))); var command2position = memoryOutput.Content.IndexOf(memoryOutput.Content.First(l => l.Contains("command2"))); Assert.IsTrue(command1position > command2position); }
public void ShouldNotSetOtputIfThePropertyDoesNotExist() { var commandWithoutOutput = new DoSomethingNTimesCommand(); var output = new MemoryOutput(); Assert.IsFalse(CommandMetaDataHelper.SetOutputProperty(commandWithoutOutput, output)); }
public void ShouldSetOtputIfThePropertyExists() { var commandWithOutput = new DoSomethingCommand(); var output = new MemoryOutput(); var result = CommandMetaDataHelper.SetOutputProperty(commandWithOutput, output); Assert.IsTrue(result); }
public void CommandLineHelpCommandShouldReturnAllCommandInfo() { var memoryOutput = new MemoryOutput(); var commandLineHelpCommand = new CommandLineHelpCommand(_commandRepository, memoryOutput); commandLineHelpCommand.Execute(); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("command1"))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("command2"))); }
public void CommandHelpCommandShouldIncludeEnumValues() { var memoryOutput = new MemoryOutput(); var commandHelpCommand = new CommandHelpCommand(typeof(DoSomethingWithEnumCommand), memoryOutput); commandHelpCommand.Execute(); Assert.IsTrue(memoryOutput.Content.Any(l => l.IndexOf("[values: Value1,Value2,Value3]", StringComparison.OrdinalIgnoreCase) >= 0)); Assert.IsTrue(memoryOutput.Content.Any(l => l.IndexOf("[default: Value2]", StringComparison.OrdinalIgnoreCase) >= 0)); }
public void CommandHelpCommandShouldIncludePropertyType() { var memoryOutput = new MemoryOutput(); var commandHelpCommand = new CommandHelpCommand(typeof(DoSomethingNTimesCommand), memoryOutput); commandHelpCommand.Execute(); Assert.IsTrue(memoryOutput.Content.Any(l => l.IndexOf("string", StringComparison.OrdinalIgnoreCase) >= 0)); Assert.IsTrue(memoryOutput.Content.Any(l => l.IndexOf("int", StringComparison.OrdinalIgnoreCase) >= 0)); }
public void CommandLineHelpCommandShouldShowNoCommandsMessageIfThereAreNoCommands() { var emptyCommandRepository = Substitute.For <ICommandRepository>(); emptyCommandRepository.GetCommandsInfo().Returns(new List <CommandInfo>()); var memoryOutput = new MemoryOutput(); var commandLineHelpCommand = new CommandLineHelpCommand(emptyCommandRepository, memoryOutput); commandLineHelpCommand.Execute(); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("There are no commands."))); }
public void CommandHelpCommandShouldReturnAllCommandInfo() { var memoryOutput = new MemoryOutput(); var commandHelpCommand = new CommandHelpCommand(typeof(DoSomethingNTimesCommand), memoryOutput); commandHelpCommand.Execute(); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("Do something n times."))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains(" That's long description line 1."))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains(" That's long description line 2."))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("-a"))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("--action"))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("Defines what should be done."))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("-r"))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("--repeat"))); Assert.IsTrue(memoryOutput.Content.Any(l => l.Contains("Number of repeats."))); Assert.IsTrue(memoryOutput.Content.Any(l => l.IndexOf("Default", StringComparison.OrdinalIgnoreCase) >= 0)); }