示例#1
0
        public void ParseArguments_InvalidFormat_ReturnsFailureResult(string arguments)
        {
            // Arrange
            var argumentsArray  = arguments.Split(" ");
            var optionsProvider = new OptionsProvider();

            // Act
            var result = optionsProvider.ParseArguments(argumentsArray);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.ParsedSuccessfully, Is.False);
            Assert.That(result.HelpText, Is.EqualTo(StandardHelpText));
        }
示例#2
0
        public void ParseArguments_ValidArguments_ReturnsSuccessResult(string arguments, int expectedNumberOfPosts)
        {
            // Arrange
            var argumentsArray  = arguments.Split(" ");
            var optionsProvider = new OptionsProvider();

            // Act
            var result = optionsProvider.ParseArguments(argumentsArray);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.ParsedSuccessfully, Is.True);
            Assert.That(result.Options.NumberOfPosts, Is.EqualTo(expectedNumberOfPosts));
        }
示例#3
0
        public void ParseArguments_ValidFormatPostCountOutOfRange_ReturnsFailureResult(int postCount)
        {
            // Arrange
            var argumentsArray  = new[] { "--posts", postCount.ToString() };
            var optionsProvider = new OptionsProvider();

            // Act
            var result = optionsProvider.ParseArguments(argumentsArray);

            // Assert
            var expectedHelpText = "Number of posts must be between 1 and 100." + Environment.NewLine + Environment.NewLine + StandardHelpText;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.ParsedSuccessfully, Is.False);
            Assert.That(result.HelpText, Is.EqualTo(expectedHelpText));
        }