24 var tokenPartitions =
new[]
26 new KeyValuePair<string, IEnumerable<string>>(
"x",
new [] {
"true" })
31 new OptionSpecification(
"x",
string.Empty,
false,
string.Empty,
Maybe.Nothing<
int>(),
Maybe.Nothing<
int>(),
'\0',
Maybe.Nothing<
object>(),
string.Empty,
string.Empty,
new List<string>(), typeof(
bool),
TargetType.Switch,
string.Empty),
32 typeof(
Simple_Options).GetProperties().Single(p => p.Name.Equals(
"BoolValue", StringComparison.Ordinal)),
33 Maybe.Nothing<
object>())
38 specProps.Where(pt => pt.Specification.IsOption()),
40 (vals, type, isScalar, isFlag) =>
TypeConverter.
ChangeType(vals, type, isScalar, isFlag, CultureInfo.InvariantCulture,
false),
41 StringComparer.Ordinal
45 Assert.NotNull(((
Ok<IEnumerable<SpecificationProperty>,
Error>)result).Success.Single(
46 a => a.Specification.IsOption()
56 var tokenPartitions =
new[]
58 new KeyValuePair<string, IEnumerable<string>>(
"s",
new[] {
"string1" }),
59 new KeyValuePair<
string, IEnumerable<string>>(
"shortandlong",
new[] {
"string2" }),
60 new KeyValuePair<
string, IEnumerable<string>>(
"shortandlong",
new[] {
"string3" }),
61 new KeyValuePair<
string, IEnumerable<string>>(
"s",
new[] {
"string4" }),
67 new OptionSpecification(
"s",
"shortandlong",
false,
string.Empty,
Maybe.Nothing<
int>(),
Maybe.Nothing<
int>(),
'\0',
Maybe.Nothing<
object>(),
string.Empty,
string.Empty,
new List<string>(), typeof(
string),
TargetType.Scalar,
string.Empty),
69 Maybe.Nothing<
object>()),
73 specProps.Where(pt => pt.Specification.IsOption()),
75 (vals, type, isScalar, isFlag) =>
TypeConverter.
ChangeType(vals, type, isScalar, isFlag, CultureInfo.InvariantCulture,
false),
76 StringComparer.Ordinal);
78 var
property = result.SucceededWith().Single();
79 Assert.True(property.Specification.IsOption());
80 Assert.True(property.Value.MatchJust(out var stringVal));
81 Assert.Equal(tokenPartitions.Last().Value.Last(), stringVal);
87 var tokenPartitions =
new[]
89 new KeyValuePair<string, IEnumerable<string>>(
"i",
new [] {
"1",
"2" }),
90 new KeyValuePair<
string, IEnumerable<string>>(
"i",
new [] {
"3" }),
91 new KeyValuePair<
string, IEnumerable<string>>(
"i",
new [] {
"4",
"5" }),
96 new OptionSpecification(
"i",
string.Empty,
false,
string.Empty,
Maybe.Nothing<
int>(),
Maybe.Nothing<
int>(),
'\0',
Maybe.Nothing<
object>(),
string.Empty,
string.Empty,
new List<string>(), typeof(IEnumerable<int>),
TargetType.Sequence,
string.Empty),
98 Maybe.Nothing<
object>())
102 specProps.Where(pt => pt.Specification.IsOption()),
104 (vals, type, isScalar, isFlag) =>
TypeConverter.
ChangeType(vals, type, isScalar, isFlag, CultureInfo.InvariantCulture,
false),
105 StringComparer.Ordinal);
107 var
property = result.SucceededWith().Single();
108 Assert.True(property.Specification.IsOption());
109 Assert.True(property.Value.MatchJust(out var sequence));
111 var expected = tokenPartitions.Aggregate(Enumerable.Empty<
int>(), (prev, part) => prev.Concat(part.Value.Select(i =>
int.Parse(i))));
112 Assert.Equal(expected, sequence);