public void GetCommand_MultipleCommandsWithSimilarName_ArgumentIsOnlyPartialCommandNameWhichMatchesMoreThanOneCommand_ResultIsNull() { // Arrange var command1 = new Mock<ICommand>(); command1.Setup(c => c.Attributes).Returns(new CommandAttributes { CommandName = "abc" }); var command2 = new Mock<ICommand>(); command2.Setup(c => c.Attributes).Returns(new CommandAttributes { CommandName = "abcd" }); var command3 = new Mock<ICommand>(); command3.Setup(c => c.Attributes).Returns(new CommandAttributes { CommandName = "abcde" }); var commandList = new List<ICommand> { command1.Object, command2.Object, command3.Object }; var customCommandProvider = new ConsoleCommandProvider(commandList); var interpreter = new CommandLineArgumentInterpreter( customCommandProvider, this.commandNameMatcher, this.commandArgumentParser, this.commandArgumentNameMatcher); var arguments = new[] { "abc" }; // Act ICommand result = interpreter.GetCommand(arguments); // Assert Assert.IsNull(result); }
public void Constructor_AllParametersAreSet_ClassIsInstantiated() { // Act var result = new ConsoleCommandProvider( this.installationStatus, this.install, this.uninstall, this.cleanup, this.packageSolution, this.packageBuildOutput, this.configureSources, this.configurePublishingTargets, this.selfUpdate, this.publishCommand, this.help); // Assert Assert.IsNotNull(result); }
public void GetCommands_ListOfCommandsIsProvided_ResultIsSameListOfCommands() { // Arrange var command1 = new Mock<ICommand>(); var command2 = new Mock<ICommand>(); var commandList = new List<ICommand> { command1.Object, command2.Object }; ICommandProvider commandProvider = new ConsoleCommandProvider(commandList); // Act var result = commandProvider.GetAvailableCommands(); // Assert Assert.AreEqual(commandList, result); }
public void GetCommands_EmptyListOfCommandsIsProvided_ResultIsEmptyListOfCommands() { // Arrange ICommandProvider commandProvider = new ConsoleCommandProvider(new List<ICommand>()); // Act var result = commandProvider.GetAvailableCommands(); // Assert Assert.AreEqual(0, result.Count); }