Наследование: ICommandLineArgumentInterpreter
        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 GetCommand_ArgumentsArrayContainsDifferentCasedCommandName_CommandIsReturned()
        {
            // Arrange
            var command = new Mock<ICommand>();
            command.Setup(c => c.Attributes).Returns(new CommandAttributes
                {
                    CommandName = "help",
                    AlternativeCommandNames = new[] { "?" }
                });

            var commandProviderMock = new Mock<ICommandProvider>();
            commandProviderMock.Setup(c => c.GetAvailableCommands()).Returns(new List<ICommand> { command.Object });

            var commandNameMatcher = new Mock<ICommandNameMatcher>();
            commandNameMatcher.Setup(c => c.IsMatch(command.Object, It.IsAny<string>())).Returns(true);

            var commandArgumentParser = new Mock<ICommandArgumentParser>();
            var commandArgumentNameMatcher = new Mock<ICommandArgumentNameMatcher>();

            ICommandLineArgumentInterpreter commandLineArgumentInterpreter = new CommandLineArgumentInterpreter(
                commandProviderMock.Object, commandNameMatcher.Object, commandArgumentParser.Object, commandArgumentNameMatcher.Object);

            var commandLineArguments = new[] { "HELP" };

            // Act
            ICommand result = commandLineArgumentInterpreter.GetCommand(commandLineArguments);

            // Assert
            Assert.AreEqual(command.Object.Attributes.CommandName, result.Attributes.CommandName);
        }
        public void GetCommand_ArgumentsArrayIsNotEmpty_CommandProviderReturnsNoCommands_ResultIsNull()
        {
            // Arrange
            var commandProviderMock = new Mock<ICommandProvider>();
            commandProviderMock.Setup(c => c.GetAvailableCommands()).Returns(new List<ICommand>());

            var commandNameMatcher = new Mock<ICommandNameMatcher>();
            var commandArgumentParser = new Mock<ICommandArgumentParser>();
            var commandArgumentNameMatcher = new Mock<ICommandArgumentNameMatcher>();

            ICommandLineArgumentInterpreter commandLineArgumentInterpreter = new CommandLineArgumentInterpreter(
                commandProviderMock.Object, commandNameMatcher.Object, commandArgumentParser.Object, commandArgumentNameMatcher.Object);

            var commandLineArguments = new[] { "commandName1" };

            // Act
            ICommand result = commandLineArgumentInterpreter.GetCommand(commandLineArguments);

            // Assert
            Assert.IsNull(result);
        }
        public void GetCommand_ArgumentsArrayIsNull_ArgumentNullExceptionIsThrown()
        {
            // Arrange
            var commandProviderMock = new Mock<ICommandProvider>();
            var commandNameMatcher = new Mock<ICommandNameMatcher>();
            var commandArgumentParser = new Mock<ICommandArgumentParser>();
            var commandArgumentNameMatcher = new Mock<ICommandArgumentNameMatcher>();

            ICommandLineArgumentInterpreter commandLineArgumentInterpreter = new CommandLineArgumentInterpreter(
                commandProviderMock.Object, commandNameMatcher.Object, commandArgumentParser.Object, commandArgumentNameMatcher.Object);

            // Act
            commandLineArgumentInterpreter.GetCommand(null);
        }
        public void GetCommand_ArgumentsArrayIsEmpty_ResultIsNull()
        {
            // Arrange
            var commandProviderMock = new Mock<ICommandProvider>();
            var commandNameMatcher = new Mock<ICommandNameMatcher>();
            var commandArgumentParser = new Mock<ICommandArgumentParser>();
            var commandArgumentNameMatcher = new Mock<ICommandArgumentNameMatcher>();

            ICommandLineArgumentInterpreter commandLineArgumentInterpreter = new CommandLineArgumentInterpreter(
                commandProviderMock.Object, commandNameMatcher.Object, commandArgumentParser.Object, commandArgumentNameMatcher.Object);

            var commandLineArguments = new string[] { };

            // Act
            ICommand result = commandLineArgumentInterpreter.GetCommand(commandLineArguments);

            // Assert
            Assert.IsNull(result);
        }