public void ParseStringArrayOptionUsingShortNameWithValueAdjacent() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-zapple", "kiwi" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new string[] { "apple", "kiwi" }, options.StringArrayValue); }
public void ParseStringArrayOptionUsingLongNameWithEqualSign() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "--strarr=apple", "kiwi" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new string[] { "apple", "kiwi" }, options.StringArrayValue); }
public void ParseStringArrayOptionUsingLongName() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "--strarr", "alfa", "beta", "gamma" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new string[] { "alfa", "beta", "gamma" }, options.StringArrayValue); }
public void ParseStringArrayOptionUsingShortNameAndStringOptionAfter() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-z", "one", "two", "three", "-s", "after" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new string[] { "one", "two", "three" }, options.StringArrayValue); Assert.AreEqual("after", options.StringValue); }
public void ParseCultureSpecificNumber() { var actualCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT"); var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-q", "1,2", "1,23", "1,234" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new double[] { 1.2, 1.23, 1.234 }, options.DoubleArrayValue); Thread.CurrentThread.CurrentCulture = actualCulture; }
public void ParseCultureSpecificNumber() { var actualCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT"); var options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-q", "1,2", "1,23", "1,234" }, options); ResultShouldBeTrue(); base.ElementsShouldBeEqual(new double[] { 1.2, 1.23, 1.234 }, options.DoubleArrayValue); Thread.CurrentThread.CurrentCulture = actualCulture; }
public void Parse_culture_specific_number() { var actualCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT"); var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-q", "1,2", "1,23", "1,234" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new double[] { 1.2, 1.23, 1.234 }, options.DoubleArrayValue); Thread.CurrentThread.CurrentCulture = actualCulture; }
public void Parse_different_arrays_together__combination_one() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-z", "one", "two", "three", "four", "-y", "1", "2", "3", "4", "-q", "0.1", "0.2", "0.3", "0.4" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.ElementsShouldBeEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.ElementsShouldBeEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "-y", "1", "2", "3", "4", "-z", "one", "two", "three", "four", "-q", "0.1", "0.2", "0.3", "0.4" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.ElementsShouldBeEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.ElementsShouldBeEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "-q", "0.1", "0.2", "0.3", "0.4", "-y", "1", "2", "3", "4", "-z", "one", "two", "three", "four" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); base.ElementsShouldBeEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.ElementsShouldBeEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); }
public void ParseDifferentArraysTogether_CombinationOne() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-z", "one", "two", "three", "four", "-y", "1", "2", "3", "4", "-q", "0.1", "0.2", "0.3", "0.4" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.AssertArrayItemEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.AssertArrayItemEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "-y", "1", "2", "3", "4", "-z", "one", "two", "three", "four", "-q", "0.1", "0.2", "0.3", "0.4" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.AssertArrayItemEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.AssertArrayItemEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "-q", "0.1", "0.2", "0.3", "0.4", "-y", "1", "2", "3", "4", "-z", "one", "two", "three", "four" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); base.AssertArrayItemEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.AssertArrayItemEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); }
public void ParseDifferentArraysTogether_CombinationTwo() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-z", "one", "two", "three", "four", "-y", "1", "2", "3", "4", "-q", "0.1", "0.2", "0.3", "0.4", "--string=after" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.AssertArrayItemEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.AssertArrayItemEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); Assert.AreEqual("after", options.StringValue); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "--string", "before", "-y", "1", "2", "3", "4", "-z", "one", "two", "three", "four", "-q", "0.1", "0.2", "0.3", "0.4" }, options); base.AssertParserSuccess(result); Assert.AreEqual("before", options.StringValue); base.AssertArrayItemEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.AssertArrayItemEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.AssertArrayItemEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "-q", "0.1", "0.2", "0.3", "0.4", "-y", "1", "2", "3", "4", "-s", "near-the-center", "-z", "one", "two", "three", "four" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); base.AssertArrayItemEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); Assert.AreEqual("near-the-center", options.StringValue); base.AssertArrayItemEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "--switch", "-z", "one", "two", "three", "four", "-y", "1", "2", "3", "4", "-i", "1234", "-q", "0.1", "0.2", "0.3", "0.4", "--string", "I'm really playing with the parser!" }, options); base.AssertParserSuccess(result); Assert.IsTrue(options.BooleanValue); base.AssertArrayItemEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.AssertArrayItemEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); Assert.AreEqual(1234, options.IntegerValue); base.AssertArrayItemEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); Assert.AreEqual("I'm really playing with the parser!", options.StringValue); }
public void ParseDoubleArrayOptionUsingShortName() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-q", "0.1", "2.3", "0.9" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new double[] { .1, 2.3, .9 }, options.DoubleArrayValue); }
public void ParseStringArrayOptionUsingShortNameWithOptionsBeforeAndAfter() { var options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-i", "191919", "-z", "one", "two", "three", "--switch", "--string=near" }, options); ResultShouldBeTrue(); options.IntegerValue.Should().Equal(191919); base.ElementsShouldBeEqual(new string[] { "one", "two", "three" }, options.StringArrayValue); options.BooleanValue.Should().Be.True(); options.StringValue.Should().Equal("near"); }
public void ParseStringArrayOptionUsingShortNameAndStringOptionBefore() { var options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-s", "before", "-z", "one", "two", "three" }, options); ResultShouldBeTrue(); options.StringValue.Should().Equal("before"); base.ElementsShouldBeEqual(new string[] { "one", "two", "three" }, options.StringArrayValue); }
public void ParseStringArrayOptionUsingShortName() { var options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-z", "alfa", "beta", "gamma" }, options); ResultShouldBeTrue(); base.ElementsShouldBeEqual(new string[] { "alfa", "beta", "gamma" }, options.StringArrayValue); }
public void PassingBadValueToAnIntegerArrayOptionFails() { var options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-y", "one", "2", "3" }, options); ResultShouldBeFalse(); options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-yone", "2", "3" }, options); ResultShouldBeFalse(); options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "--intarr", "1", "two", "3" }, options); ResultShouldBeFalse(); options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "--intarr=1", "2", "three" }, options); ResultShouldBeFalse(); }
public void Parse_string_array_option_using_short_name_with_options_before_and_after() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-i", "191919", "-z", "one", "two", "three", "--switch", "--string=near" }, options); result.Should().BeTrue(); options.IntegerValue.Should().Be(191919); base.ElementsShouldBeEqual(new string[] { "one", "two", "three" }, options.StringArrayValue); options.BooleanValue.Should().BeTrue(); options.StringValue.Should().Be("near"); }
public void PassingBadValueToAnIntegerArrayOptionFails() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-y", "one", "2", "3" }, options); base.AssertParserFailure(result); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "-yone", "2", "3" }, options); base.AssertParserFailure(result); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "--intarr", "1", "two", "3" }, options); base.AssertParserFailure(result); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "--intarr=1", "2", "three" }, options); base.AssertParserFailure(result); }
public void Parse_string_array_option_using_short_name() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-z", "alfa", "beta", "gamma" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new string[] { "alfa", "beta", "gamma" }, options.StringArrayValue); }
public void ParseStringArrayOptionUsingShortNameWithValueAdjacent() { var options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-zapple", "kiwi" }, options); ResultShouldBeTrue(); base.ElementsShouldBeEqual(new string[] { "apple", "kiwi" }, options.StringArrayValue); }
public void Parse_integer_array_option_using_short_name() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-y", "1", "2", "3" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new int[] { 1, 2, 3 }, options.IntegerArrayValue); }
public void Parse_double_array_option_using_short_name() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-q", "0.1", "2.3", "0.9" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new double[] { .1, 2.3, .9 }, options.DoubleArrayValue); }
public void Parse_different_arrays_together__combination_two() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-z", "one", "two", "three", "four", "-y", "1", "2", "3", "4", "-q", "0.1", "0.2", "0.3", "0.4", "--string=after" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.ElementsShouldBeEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.ElementsShouldBeEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options.StringValue.Should().Be("after"); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "--string", "before", "-y", "1", "2", "3", "4", "-z", "one", "two", "three", "four", "-q", "0.1", "0.2", "0.3", "0.4" }, options); result.Should().BeTrue(); options.StringValue.Should().Be("before"); base.ElementsShouldBeEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); base.ElementsShouldBeEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.ElementsShouldBeEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "-q", "0.1", "0.2", "0.3", "0.4", "-y", "1", "2", "3", "4", "-s", "near-the-center", "-z", "one", "two", "three", "four" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); base.ElementsShouldBeEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); options.StringValue.Should().Be("near-the-center"); base.ElementsShouldBeEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "--switch", "-z", "one", "two", "three", "four", "-y", "1", "2", "3", "4", "-i", "1234", "-q", "0.1", "0.2", "0.3", "0.4", "--string", "I'm really playing with the parser!" }, options); result.Should().BeTrue(); options.BooleanValue.Should().BeTrue(); base.ElementsShouldBeEqual(new string[] { "one", "two", "three", "four" }, options.StringArrayValue); base.ElementsShouldBeEqual(new int[] { 1, 2, 3, 4 }, options.IntegerArrayValue); options.IntegerValue.Should().Be(1234); base.ElementsShouldBeEqual(new double[] { .1, .2, .3, .4 }, options.DoubleArrayValue); options.StringValue.Should().Be("I'm really playing with the parser!"); }
public void ParseIntegerArrayOptionUsingShortName() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-y", "1", "2", "3" }, options); base.AssertParserSuccess(result); base.AssertArrayItemEqual(new int[] { 1, 2, 3 }, options.IntegerArrayValue); }
public void Parse_string_array_option_using_short_name_with_value_adjacent() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-zapple", "kiwi" }, options); result.Should().BeTrue(); base.ElementsShouldBeEqual(new string[] { "apple", "kiwi" }, options.StringArrayValue); }
public void ParseStringArrayOptionUsingShortNameWithOptionsBeforeAndAfter() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-i", "191919", "-z", "one", "two", "three", "--switch", "--string=near" }, options); base.AssertParserSuccess(result); Assert.AreEqual(191919, options.IntegerValue); base.AssertArrayItemEqual(new string[] { "one", "two", "three" }, options.StringArrayValue); Assert.IsTrue(options.BooleanValue); Assert.AreEqual("near", options.StringValue); }
public void Passing_bad_value_to_an_integer_array_option_fails() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-y", "one", "2", "3" }, options); result.Should().BeFalse(); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "-yone", "2", "3" }, options); result.Should().BeFalse(); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "--intarr", "1", "two", "3" }, options); result.Should().BeFalse(); options = new SimpleOptionsWithArray(); parser = new CommandLineParser(); result = parser.ParseArguments(new string[] { "--intarr=1", "2", "three" }, options); result.Should().BeFalse(); }
public void PassingNoValueToAStringArrayOptionFails() { var options = new SimpleOptionsWithArray(); bool result = base.Parser.ParseArguments(new string[] { "-z" }, options); base.AssertParserFailure(result); options = new SimpleOptionsWithArray(); result = base.Parser.ParseArguments(new string[] { "--strarr" }, options); base.AssertParserFailure(result); }
public void Passing_no_value_to_a_string_array_option_fails() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-z" }, options); result.Should().BeFalse(); options = new SimpleOptionsWithArray(); result = parser.ParseArguments(new string[] { "--strarr" }, options); result.Should().BeFalse(); }
public void Parse_string_array_option_using_short_name_and_string_option_before() { var options = new SimpleOptionsWithArray(); var parser = new CommandLineParser(); var result = parser.ParseArguments(new string[] { "-s", "before", "-z", "one", "two", "three" }, options); result.Should().BeTrue(); options.StringValue.Should().Be("before"); base.ElementsShouldBeEqual(new string[] { "one", "two", "three" }, options.StringArrayValue); }
public void PassingNoValueToAStringArrayOptionFails() { var options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "-z" }, options); ResultShouldBeFalse(); options = new SimpleOptionsWithArray(); Result = base.Parser.ParseArguments(new string[] { "--strarr" }, options); ResultShouldBeFalse(); }