4using System.Collections.Generic;
24 false,
string.Empty,
Maybe.Nothing<
int>(),
Maybe.Nothing<
int>(),
',',
null,
string.Empty,
string.Empty,
new List<string>(), typeof(IEnumerable<string>),
TargetType.Sequence,
string.Empty)};
30 Enumerable.Empty<
Token>().Concat(
new[] { Token.Name(
"i"), Token.Value(
"10"),
31 Token.Name(
"string-seq"), Token.Value(
"aaa,bb,cccc"), Token.Name(
"switch") }),
32 Enumerable.Empty<
Error>()),
47 false,
string.Empty,
Maybe.Nothing<
int>(),
Maybe.Nothing<
int>(),
',',
null,
string.Empty,
string.Empty,
new List<string>(), typeof(IEnumerable<string>),
TargetType.Sequence,
string.Empty)};
53 Enumerable.Empty<
Token>().Concat(
new[] { Token.Name(
"x"),
54 Token.Name(
"string-seq"), Token.Value(
"aaa,bb,cccc"), Token.Name(
"switch") }),
55 Enumerable.Empty<
Error>()),
68 var expectedTokens =
new[] {
71 Func<string, bool> nameLookup =
72 name => name.Equals(
"x") || name.Equals(
"string-seq") || name.Equals(
"switch");
78 Enumerable.Empty<
Token>()
81 Token.Name(
"x"), Token.Name(
"string-seq"), Token.Value(
"value0", true), Token.Value(
"bb"),
82 Token.Name(
"unknown"), Token.Value(
"value0", true), Token.Name(
"switch") })
87 result.Should().BeEquivalentTo(expectedTokens);
96 var expectedTokens =
new[] {
99 Func<string, bool> nameLookup =
100 name => name.Equals(
"x") || name.Equals(
"string-seq") || name.Equals(
"switch");
106 Enumerable.Empty<
Token>()
109 Token.Name(
"x"), Token.Name(
"string-seq"), Token.Value(
"value0", true), Token.Value(
"bb"),
110 Token.Name(
"unknown"), Token.Name(
"switch") })
115 result.Should().BeEquivalentTo(expectedTokens);
128 var args =
new[] {
"--connectionString=Server=localhost;Data Source=(LocalDB)\v12.0;Initial Catalog=temp;" };
132 var tokens = result.SucceededWith();
134 Assert.NotNull(tokens);
135 Assert.Equal(2, tokens.Count());
136 Assert.Equal(
"connectionString", tokens.First().Text);
137 Assert.Equal(
"Server=localhost;Data Source=(LocalDB)\v12.0;Initial Catalog=temp;", tokens.Last().Text);
143 var args =
new[] {
"--option1 = fail",
"--option2= fail" };
147 var tokens = result.SuccessMessages();
149 Assert.NotNull(tokens);
150 Assert.Equal(2, tokens.Count());
151 Assert.Equal(
ErrorType.BadFormatTokenError, tokens.First().Tag);
152 Assert.Equal(
ErrorType.BadFormatTokenError, tokens.Last().Tag);
156 [InlineData(
new[] {
"-a",
"-" }, 2,
"a",
"-")]
157 [InlineData(
new[] {
"--file",
"-" }, 2,
"file",
"-")]
158 [InlineData(
new[] {
"-f-" }, 2,
"f",
"-")]
159 [InlineData(
new[] {
"--file=-" }, 2,
"file",
"-")]
160 [InlineData(
new[] {
"-a",
"--" }, 1,
"a",
"a")]
166 var tokens = result.SucceededWith().ToList();
168 tokens.Should().NotBeNull();
169 tokens.Count.Should().Be(countExcepted);
170 tokens.First().Text.Should().Be(first);
171 tokens.Last().Text.Should().Be(last);
The Maybe type models an optional value. A value of type Maybe a either contains a value of type a (r...
static Maybe< char > HavingSeparator(string name, IEnumerable< OptionSpecification > specifications, StringComparer comparer)
static Token Value(string text)
static Token Name(string text)
static Result< IEnumerable< Token >, Error > ExplodeOptionList(Result< IEnumerable< Token >, Error > tokenizerResult, Func< string, Maybe< char > > optionSequenceWithSeparatorLookup)
static Result< IEnumerable< Token >, Error > Tokenize(IEnumerable< string > arguments, Func< string, NameLookupResult > nameLookup)
static IEnumerable< Token > Normalize(IEnumerable< Token > tokens, Func< string, bool > nameLookup)
Normalizes the given tokens .
void Explode_scalar_with_separator_in_even_args_input_returns_sequence()
void Should_return_error_if_option_format_with_equals_is_not_correct()
void Should_properly_parse_option_with_equals_in_value()
void Normalize_should_remove_all_names_of_non_existing_names()
void Single_dash_as_a_value(string[] args, int countExcepted, string first, string last)
void Normalize_should_remove_all_names_and_values_with_explicit_assignment_of_non_existing_names()
void Explode_scalar_with_separator_in_odd_args_input_returns_sequence()
Represents the result of a successful computation.
Represents the result of a computation.
ErrorType
Discriminator enumeration of CommandLine.Error derivates.