Inheritance: OptionsBase
        public void AllowSingleDashAsOptionInputValue()
        {
            var options = new SimpleOptions();
            bool result = base.Parser.ParseArguments(new string[] { "--string", "-" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual("-", options.StringValue);
        }
        public void AllowSingleDashAsOptionInputValue()
        {
            var options = new SimpleOptions();
            Result = base.Parser.ParseArguments(new string[] { "--string", "-" }, options);

            ResultShouldBeTrue();
            options.StringValue.Should().Equal("-");
        }
 public void ParseStringOption()
 {
     var options = new SimpleOptions();
     bool result = base.Parser.ParseArguments(new string[] { "-s", "something" }, options);
     
     base.AssertParserSuccess(result);
     Assert.AreEqual("something", options.StringValue);
     Console.WriteLine(options);
 }
        public void Allow_single_dash_as_option_input_value()
        {
            var options = new SimpleOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "--string", "-" }, options);

            result.Should().BeTrue();
            options.StringValue.Should().Be("-");
        }
        public void ParseStringIntegerBoolOptions()
        {
            var options = new SimpleOptions();
            bool result = base.Parser.ParseArguments(
                    new string[] { "-s", "another string", "-i100", "--switch" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual("another string", options.StringValue);
            Assert.AreEqual(100, options.IntegerValue);
            Assert.AreEqual(true, options.BooleanValue);
            Console.WriteLine(options);
        }
        public void ParseStringIntegerBoolOptions()
        {
            var options = new SimpleOptions();
            bool result = CommandLineParser.Default.ParseArguments(
                    new string[] { "-s", "another string", "-i100", "--switch" }, options);

            result.Should().Be.True();
            options.StringValue.Should().Equal("another string");
            options.IntegerValue.Should().Equal(100);
            options.BooleanValue.Should().Be.True();
            Console.WriteLine(options);
        }
        public void Parse_string_integer_bool_options()
        {
            var options = new SimpleOptions();
            bool result = Parser.Default.ParseArguments(
                    new string[] { "-s", "another string", "-i100", "--switch" }, options);

            result.Should().BeTrue();
            options.StringValue.Should().Be("another string");
            options.IntegerValue.Should().Be(100);
            options.BooleanValue.Should().BeTrue();
            Console.WriteLine(options);
        }
        public void ParseStrictBadInputFailsAndExits()
        {
            var options = new SimpleOptions();
            var testWriter = new StringWriter();

            Result = Parser.ParseArgumentsStrict(new string[] {"--bad", "--input"}, options, testWriter);

            ResultShouldBeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really produced all help?
            lines.Should().Count.Exactly(8);
            // Verify just significant output
            lines[5].Trim().Should().Equal("-s, --string");
            lines[6].Trim().Should().Equal("-i");
            lines[7].Trim().Should().Equal("--switch");
        }
        public void Parse_strict_bad_input_fails_and_exits()
        {
            var options = new SimpleOptions();
            var testWriter = new StringWriter();

            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new Parser();
            var result = parser.ParseArgumentsStrict(new string[] {"--bad", "--input"}, options, testWriter);

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really produced all help?
            lines.Should().HaveCount(n => n == 8);
            // Verify just significant output
            lines[5].Trim().Should().Be("-s, --string");
            lines[6].Trim().Should().Be("-i");
            lines[7].Trim().Should().Be("--switch");
        }
        public void ParsingNonExistentShortOptionFailsWithoutThrowingAnException()
        {
            var options = new SimpleOptions();
            bool result = base.Parser.ParseArguments(new string[] { "-x" }, options);

            base.AssertParserFailure(result);
        }
        public void Parse_negative_integer_value()
        {
            var options = new SimpleOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "-i", "-4096" }, options);

            result.Should().BeTrue();
            options.IntegerValue.Should().Be(-4096);
        }
        public void Parse_string_option()
        {
            var options = new SimpleOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "-s", "something" }, options);

            result.Should().BeTrue();
            options.StringValue.Should().Be("something");
            Console.WriteLine(options);
        }
        public void ShortOptionRefusesEqualToken()
        {
            var options = new SimpleOptions();

            Result = base.Parser.ParseArguments(new string[] { "-i=10" }, options);
            ResultShouldBeFalse();
            Console.WriteLine(options);
        }
        public void PassingNoValueToAStringTypeLongOptionFails()
        {
            var options = new SimpleOptions();
            Result = base.Parser.ParseArguments(new string[] { "--string" }, options);

            ResultShouldBeFalse();
        }
        public void ParsingNonExistentShortOptionFailsWithoutThrowingAnException()
        {
            var options = new SimpleOptions();
            Result = base.Parser.ParseArguments(new string[] { "-x" }, options);

            ResultShouldBeFalse();
        }
        public void ParseStringOption()
        {
            var options = new SimpleOptions();
            Result = base.Parser.ParseArguments(new string[] { "-s", "something" }, options);

            ResultShouldBeTrue();
            options.StringValue.Should().Equal("something");
            Console.WriteLine(options);
        }
        public void ParseNegativeIntegerValue()
        {
            var options = new SimpleOptions();
            Result = base.Parser.ParseArguments(new string[] { "-i", "-4096" }, options);

            ResultShouldBeTrue();
            options.IntegerValue.Should().Equal(-4096);
        }
        public void Parsing_non_existent_short_option_fails_without_throwing_an_exception()
        {
            var options = new SimpleOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "-x" }, options);

            result.Should().BeFalse();
        }
        public void ShortOptionRefusesEqualToken()
        {
            var options = new SimpleOptions();

            Assert.IsFalse(base.Parser.ParseArguments(new string[] { "-i=10" }, options));
            Console.WriteLine(options);
        }
        public void PassingNoValueToAStringTypeLongOptionFails()
        {
            var options = new SimpleOptions();
            bool result = base.Parser.ParseArguments(new string[] { "--string" }, options);

            base.AssertParserFailure(result);
        }
        public void Passing_no_value_to_a_string_type_long_option_fails()
        {
            var options = new SimpleOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "--string" }, options);

            result.Should().BeFalse();
        }
 public void Short_option_refuses_equal_token()
 {
     var options = new SimpleOptions();
     var parser = new CommandLineParser();
     var result = parser.ParseArguments(new string[] { "-i=10" }, options);
     result.Should().BeFalse();
     Console.WriteLine(options);
 }
        public void ParseNegativeIntegerValue()
        {
            var options = new SimpleOptions();
            bool result = base.Parser.ParseArguments(new string[] { "-i", "-4096" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual(-4096, options.IntegerValue);
        }