3using Microsoft.FSharp.Core;
10using FluentAssertions;
13using System.Collections.Generic;
14using System.Globalization;
26 Maybe.Just<Func<T>>(() =>
new T()),
29 StringComparer.Ordinal,
31 CultureInfo.InvariantCulture,
42 Maybe.Just<Func<T>>(() =>
new T()),
45 StringComparer.Ordinal,
47 CultureInfo.InvariantCulture,
56 Maybe.Nothing<Func<T>>(),
59 StringComparer.Ordinal,
61 CultureInfo.InvariantCulture,
75 var result = InvokeBuild<Simple_Options>(
79 result.Should().BeEquivalentTo(expectedResult);
83 [InlineData(
new[] {
"-123" }, -123L)]
84 [InlineData(
new[] {
"-1" }, -1L)]
85 [InlineData(
new[] {
"-9223372036854775807" }, -9223372036854775807)]
91 var result = InvokeBuild<Simple_Options>(
99 [InlineData(
new[] {
"0.123" }, .123D)]
100 [InlineData(
new[] {
"-0.123" }, -0.123D)]
101 [InlineData(
new[] {
"1.0123456789" }, 1.0123456789D)]
102 [InlineData(
new[] {
"-1.0123456789" }, -1.0123456789D)]
103 [InlineData(
new[] {
"0" }, 0
D)]
109 var result = InvokeBuild<Simple_Options_With_Double_Value>(
117 [InlineData(
new[] {
"--int-seq",
"1",
"20",
"300",
"4000" },
new[] { 1, 20, 300, 4000 })]
118 [InlineData(
new[] {
"--int-seq=1",
"20",
"300",
"4000" },
new[] { 1, 20, 300, 4000 })]
119 [InlineData(
new[] {
"--int-seq",
"2147483647" },
new[] { 2147483647 })]
120 [InlineData(
new[] {
"--int-seq=2147483647" },
new[] { 2147483647 })]
121 [InlineData(
new[] {
"--int-seq",
"-1",
"20",
"-3",
"0" },
new[] { -1, 20, -3, 0 })]
122 [InlineData(
new[] {
"--int-seq=-1",
"20",
"-3",
"0" },
new[] { -1, 20, -3, 0 })]
128 var result = InvokeBuild<Options_With_Sequence>(
136 [InlineData(
new[] {
"-i",
"10",
"20",
"30" },
new[] { 10, 20, 30 })]
137 [InlineData(
new[] {
"-i",
"10",
"20",
"30",
"40" },
new[] { 10, 20, 30, 40 })]
138 [InlineData(
new[] {
"-i10",
"20",
"30" },
new[] { 10, 20, 30 })]
139 [InlineData(
new[] {
"-i10",
"20",
"30",
"40" },
new[] { 10, 20, 30, 40 })]
145 var result = InvokeBuild<Simple_Options>(
153 [InlineData(
new[] {
"-s",
"just-one" },
new[] {
"just-one" })]
154 [InlineData(
new[] {
"-sjust-one-samearg" },
new[] {
"just-one-samearg" })]
155 [InlineData(
new[] {
"-s",
"also-two",
"are-ok" },
new[] {
"also-two",
"are-ok" })]
156 [InlineData(
new[] {
"--string-seq",
"one",
"two",
"three" },
new[] {
"one",
"two",
"three" })]
157 [InlineData(
new[] {
"--string-seq=one",
"two",
"three",
"4" },
new[] {
"one",
"two",
"three",
"4" })]
163 var result = InvokeBuild<Options_With_Sequence_And_Only_Min_Constraint>(
171 [InlineData(
new[] {
"-s",
"just-one" },
new[] {
"just-one" })]
172 [InlineData(
new[] {
"-sjust-one-samearg" },
new[] {
"just-one-samearg" })]
173 [InlineData(
new[] {
"-s",
"also-two",
"are-ok" },
new[] {
"also-two",
"are-ok" })]
174 [InlineData(
new[] {
"--string-seq",
"one",
"two",
"three" },
new[] {
"one",
"two",
"three" })]
180 var result = InvokeBuild<Options_With_Sequence_And_Only_Max_Constraint>(
194 var result = InvokeBuild<Options_With_Sequence_And_Only_Min_Constraint>(
208 var result = InvokeBuild<Options_With_Sequence_And_Only_Min_Constraint_For_Value>(
219 var expectedResult =
new[] {
"one",
"two",
"three" };
222 var result = InvokeBuild<Options_With_Sequence_And_Only_Max_Constraint>(
223 new[] {
"--string-seq=one",
"two",
"three",
"this-is-too-much" });
237 var result = InvokeBuild<Options_With_Sequence_And_Only_Max_Constraint_For_Value>(
238 new[] {
"one",
"two",
"three",
"this-is-too-much" });
245 [InlineData(
new[] {
"--colors",
"Red" },
Colors.Red)]
246 [InlineData(
new[] {
"--colors",
"Green" },
Colors.Green)]
247 [InlineData(
new[] {
"--colors",
"Blue" },
Colors.Blue)]
248 [InlineData(
new[] {
"--colors",
"0" },
Colors.Red)]
249 [InlineData(
new[] {
"--colors",
"1" },
Colors.Green)]
250 [InlineData(
new[] {
"--colors",
"2" },
Colors.Blue)]
256 var result = InvokeBuild<Simple_Options_With_Enum>(
264 [InlineData(
new[] {
"--colors",
"red" },
Colors.Red)]
265 [InlineData(
new[] {
"--colors",
"green" },
Colors.Green)]
266 [InlineData(
new[] {
"--colors",
"blue" },
Colors.Blue)]
267 [InlineData(
new[] {
"--colors",
"0" },
Colors.Red)]
268 [InlineData(
new[] {
"--colors",
"1" },
Colors.Green)]
269 [InlineData(
new[] {
"--colors",
"2" },
Colors.Blue)]
275 var result = InvokeBuildEnumValuesCaseIgnore<Simple_Options_With_Enum>(
289 var result = InvokeBuild<Simple_Options_With_Enum>(
290 new[] {
"--colors",
"3" });
303 var result = InvokeBuild<Simple_Options_With_Enum>(
304 new[] {
"--colors",
"Yellow" });
317 var result = InvokeBuild<Simple_Options_With_Enum>(
318 new[] {
"--colors",
"RED" });
330 StringValue =
string.Empty,
332 StringSequence =
new[] {
"a",
"b",
"c" },
337 var result = InvokeBuild<Simple_Options_With_Values>(
338 new[] {
"10",
"a",
"b",
"c",
"20" });
345 [InlineData(
new[] {
"987654321" },
new[] { 987654321L })]
346 [InlineData(
new[] {
"1",
"2",
"3",
"4",
"5",
"6" },
new[] { 1L, 2L, 3L, 4L, 5L, 6L })]
347 [InlineData(
new string[] { },
new long[] { })]
348 [InlineData(
new[] {
"-1",
"2",
"9876543210",
"-4",
"0" },
new[] { -1L, 2L, 9876543210L, -4L, 0L })]
349 [InlineData(
new[] {
"0",
"200000",
"300000",
"400000",
"-500000",
"600000",
"700000",
"800000",
"900000",
"-99999999" },
new[] { 0L, 200000L, 300000L, 400000L, -500000L, 600000L, 700000L, 800000L, 900000L, -99999999L })]
355 var result = InvokeBuild<Options_With_Sequence_Without_Range_For_Value>(
363 [InlineData(
new[] {
"--long-seq",
"1;1234;59678" },
new[] { 1L, 1234L, 59678L })]
364 [InlineData(
new[] {
"--long-seq=1;1234;59678" },
new[] { 1L, 1234L, 59678L })]
365 [InlineData(
new[] {
"--long-seq",
"-978;1234;59678;0" },
new[] { -978L, 1234L, 59678L, 0L })]
366 [InlineData(
new[] {
"--long-seq=-978;1234;59678;0" },
new[] { -978L, 1234L, 59678L, 0L })]
372 var result = InvokeBuild<Options_With_Sequence_Having_Separator_Set>(
380 [InlineData(
new[] {
"-s",
"here-one-elem-but-no-sep" },
new[] {
"here-one-elem-but-no-sep" })]
381 [InlineData(
new[] {
"-shere-one-elem-but-no-sep" },
new[] {
"here-one-elem-but-no-sep" })]
382 [InlineData(
new[] {
"-s",
"eml1@xyz.com,test@unit.org,xyz@srv.it" },
new[] {
"eml1@xyz.com",
"test@unit.org",
"xyz@srv.it" })]
383 [InlineData(
new[] {
"-sInlineData@iscool.org,test@unit.org,xyz@srv.it,another,the-last-one" },
new[] {
"InlineData@iscool.org",
"test@unit.org",
"xyz@srv.it",
"another",
"the-last-one" })]
389 var result = InvokeBuild<Options_With_Sequence_Having_Separator_Set>(
405 StringValue =
"str1",
407 StringSequence =
new[] {
"-a",
"--bee",
"-c" },
410 var arguments =
new[] {
"--stringvalue",
"str1",
"--",
"10",
"-a",
"--bee",
"-c",
"20" };
419 StringComparer.Ordinal,
421 CultureInfo.InvariantCulture,
434 var expectedResult =
new[]
441 var result = InvokeBuild<Options_With_Two_Sets>(
442 new[] {
"--weburl",
"http://mywebsite.org/",
"--ftpurl",
"fpt://ftpsite.org/" });
458 var result = InvokeBuild<Options_With_Required_Set_To_True_Within_Same_Set>(
459 new[] {
"--ftpurl",
"str1",
"--weburl",
"str2" });
470 var expectedResult =
new[]
476 var result = InvokeBuild<Options_With_Required_Set_To_True_Within_Same_Set>(
490 var result = InvokeBuild<Options_With_Required_Set_To_True>(
504 var result = InvokeBuild<Simple_Options>(
505 new[] {
"-i",
"10" });
518 var result = InvokeBuild<Simple_Options>(
519 new[] {
"--stringvalue",
"abc",
"--xyz" });
532 var result = InvokeBuild<Simple_Options>(
533 new[] {
"-z",
"-x" });
546 var result = InvokeBuild<Simple_Options>(
554 [InlineData(
new[] {
"--stringvalue",
"this-value" },
"this-value")]
555 [InlineData(
new[] {
"--stringvalue=this-other" },
"this-other")]
561 var result = InvokeBuild<Simple_Options>(
575 var result = InvokeBuild<Options_With_Required_Set_To_True_For_Values>(
583 [InlineData(
new[] {
"--stringvalue",
"䏿–‡" },
"䏿–‡")]
584 [InlineData(
new[] {
"--stringvalue=䏿–‡" },
"䏿–‡")]
585 [InlineData(
new[] {
"--stringvalue",
"日本人" },
"日本人")]
586 [InlineData(
new[] {
"--stringvalue=日本人" },
"日本人")]
592 var result = InvokeBuild<Simple_Options>(
606 var result = InvokeBuild<Options_With_Sequence_Having_Both_Min_And_Max_Equal>(
607 new[] {
"one",
"two",
"this-is-too-much" });
614 [InlineData(
new[] {
"-i",
"10" }, 10)]
615 [InlineData(
new string[] { },
null)]
616 [InlineData(
new[] {
"-i9999" }, 9999)]
617 [InlineData(
new[] {
"--nullable-int=-1" }, -1)]
623 var result = InvokeBuild<Options_With_Nullables>(
631 [InlineData(
new[] {
"10" }, 10L)]
632 [InlineData(
new string[] { },
null)]
633 [InlineData(
new[] {
"9999" }, 9999L)]
634 [InlineData(
new[] {
"-1" }, -1L)]
640 var result = InvokeBuild<Options_With_Nullables>(
649 [InlineData(
new[] {
"--filename",
"log-20150626.txt" },
"log-20150626.txt",
true)]
650 [InlineData(
new string[] { },
null,
false)]
656 var result = InvokeBuild<Options_With_FSharpOption>(
668 [InlineData(
new[] {
"1234567" }, 1234567,
true)]
669 [InlineData(
new string[] { },
default(
int),
false)]
675 var result = InvokeBuild<Options_With_FSharpOption>(
692 Action test = () => InvokeBuild<Options_With_Min_Set_To_Zero>(
696 Assert.Throws<InvalidOperationException>(test);
703 Action test = () => InvokeBuild<Options_With_Max_Set_To_Zero>(
707 Assert.Throws<InvalidOperationException>(test);
714 Action test = () => InvokeBuild<Options_With_Both_Min_And_Max_Set_To_Zero>(
718 Assert.Throws<InvalidOperationException>(test);
722 [InlineData(
new[] {
"--weburl",
"value.com",
"--verbose" },
ParserResultType.Parsed, 0)]
723 [InlineData(
new[] {
"--ftpurl",
"value.org",
"--interactive" },
ParserResultType.Parsed, 0)]
724 [InlineData(
new[] {
"--weburl",
"value.com",
"--verbose",
"--interactive" },
ParserResultType.Parsed, 0)]
725 [InlineData(
new[] {
"--ftpurl=fvalue",
"--weburl=wvalue" },
ParserResultType.NotParsed, 2)]
726 [InlineData(
new[] {
"--interactive",
"--weburl=wvalue",
"--verbose",
"--ftpurl=wvalue" },
ParserResultType.NotParsed, 2)]
730 var result = InvokeBuild<Options_With_Named_And_Empty_Sets>(
745 [InlineData(
new[] {
"--stringvalue",
"abc",
"--stringvalue",
"def" }, 1)]
749 var result = InvokeBuild<Simple_Options>(
757 [InlineData(
new[] {
"-s",
"abc",
"-s",
"def" }, 1)]
761 var result = InvokeBuild<Simple_Options>(
769 [InlineData(
new[] {
"--shortandlong",
"abc",
"--shortandlong",
"def" }, 1)]
773 var result = InvokeBuild<Simple_Options>(
781 [InlineData(
new[] {
"-s",
"abc",
"--shortandlong",
"def" }, 1)]
785 var result = InvokeBuild<Simple_Options>(
793 [InlineData(
new[] {
"--inputfile=file1.bin" },
"file1.bin")]
794 [InlineData(
new[] {
"--inputfile",
"file2.txt" },
"file2.txt")]
798 var result = InvokeBuild<Options_With_Only_Explicit_Interface>(
807 [InlineData(
new[] {
"--inputfile=file1.bin" },
"file1.bin")]
808 [InlineData(
new[] {
"--inputfile",
"file2.txt" },
"file2.txt")]
812 var result = InvokeBuild<Options_With_Interface>(
822 [InlineData(
new[] {
"--weburl=value.com",
"-a" },
ParserResultType.Parsed, 0)]
823 [InlineData(
new[] {
"--ftpurl=value.org",
"-a" },
ParserResultType.Parsed, 0)]
824 [InlineData(
new[] {
"--weburl=value.com",
"--ftpurl=value.org" },
ParserResultType.NotParsed, 2)]
825 [InlineData(
new[] {
"--weburl=value.com",
"--ftpurl=value.org",
"-a" },
ParserResultType.NotParsed, 2)]
830 var result = InvokeBuild<Options_With_Two_Option_Required_Set_To_True_And_Two_Sets>(
851 var result = InvokeBuild<Options_With_Required_Set_To_True_For_Values>(
865 var result = InvokeBuild<Options_With_Scalar_Value_And_Adjacent_SequenceString>(
876 var expectedResult =
new Simple_Options { StringValue =
"strval0", IntSequence =
new[] { 9, 7, 8 }, BoolValue =
true, LongValue = 9876543210L };
879 var result = InvokeBuild<Simple_Options>(
880 new[] {
"--stringvalue=strval0",
"-i",
"9",
"7",
"8",
"-x",
"9876543210" });
887 [InlineData(
new string[] { }, 2)]
888 [InlineData(
new[] {
"--str=val0" }, 1)]
889 [InlineData(
new[] {
"--long=9" }, 1)]
890 [InlineData(
new[] {
"--int=7" }, 2)]
891 [InlineData(
new[] {
"--str",
"val1",
"--int=3" }, 1)]
892 [InlineData(
new[] {
"--long",
"9",
"--int=11" }, 1)]
896 var result = InvokeBuild<Options_With_Two_Options_Having_Required_Set_To_True>(
911 var result = InvokeBuildImmutable<Immutable_Simple_Options>(
920 [Trait(
"Category",
"Immutable")]
926 Action act = () => InvokeBuildImmutable<Immutable_Simple_Options_Invalid_Ctor_Args>(
931 "Type CommandLine.Tests.Fakes.Immutable_Simple_Options_Invalid_Ctor_Args appears to be Immutable with invalid constructor. Check that constructor arguments have the same name and order of their underlying Type. Constructor Parameters can be ordered as: '(stringvalue, intsequence, boolvalue, longvalue)'";
932 act.Should().Throw<InvalidOperationException>().WithMessage(expectedMsg);
942 var result = InvokeBuild<Options_With_Uri_And_SimpleType>(
943 new[] {
"--endpoint=http://localhost/test/",
"custom-value" });
956 var result = InvokeBuild<Options_With_Property_Throwing_Exception>(
957 new[] {
"-e",
"bad" });
972 var result = InvokeBuild<Options_With_InvalidDefaults>(
973 new[] { name,
"bad" });
981 [InlineData(
new[] {
"--stringvalue",
"x-" },
"x-")]
982 [InlineData(
new[] {
"--stringvalue",
"x--" },
"x--")]
983 [InlineData(
new[] {
"--stringvalue",
"x---" },
"x---")]
984 [InlineData(
new[] {
"--stringvalue=x-x" },
"x-x")]
985 [InlineData(
new[] {
"--stringvalue=x--x" },
"x--x")]
986 [InlineData(
new[] {
"--stringvalue=x---x" },
"x---x")]
987 [InlineData(
new[] {
"--stringvalue",
"5366ebc4-7aa7-4d5a-909c-a415a291a5ad" },
"5366ebc4-7aa7-4d5a-909c-a415a291a5ad")]
988 [InlineData(
new[] {
"--stringvalue=5366ebc4-7aa7-4d5a-909c-a415a291a5ad" },
"5366ebc4-7aa7-4d5a-909c-a415a291a5ad")]
994 var result = InvokeBuild<Simple_Options>(
1002 [InlineData(
new[] {
"--help" },
ErrorType.UnknownOptionError)]
1008 var result = InvokeBuild<Simple_Options>(arguments, autoHelp:
false);
1012 .Which.
Errors.Should().ContainSingle()
1013 .Which.Tag.Should().Be(errorType);
1017 [InlineData(
new[] {
"--help" },
true)]
1018 [InlineData(
new[] {
"-h" },
true)]
1019 [InlineData(
new[] {
"-x" },
false)]
1025 var result = InvokeBuild<Options_With_Custom_Help_Option>(arguments, autoHelp:
false);
1029 .Which.
Value.Help.Should().Be(isHelp);
1033 [InlineData(
new[] {
"--version" },
ErrorType.UnknownOptionError)]
1039 var result = InvokeBuild<Simple_Options>(arguments, autoVersion:
false);
1043 .Which.
Errors.Should().ContainSingle()
1044 .Which.Tag.Should().Be(errorType);
1048 [InlineData(
new[] {
"--version" },
true)]
1049 [InlineData(
new[] {
"-v" },
true)]
1050 [InlineData(
new[] {
"-s",
"s" },
false)]
1056 var result = InvokeBuild<Options_With_Custom_Version_Option>(arguments, autoVersion:
false);
1060 .Which.
Value.MyVersion.Should().Be(isVersion);
1070 var result = InvokeBuild<Options_With_Guid>(
1084 var result = InvokeBuild<Options_With_TimeSpan>(
1085 new[] {
"--duration=00:42:00" });
1096 var result = InvokeBuild<Options_With_TimeSpan>(
new[] {
"--duration=\"00:42:00\"" });
1101 outcome.Should().NotBeNull();
1102 outcome.
Errors.Should().NotBeNullOrEmpty()
1111 Action act = () => InvokeBuild<ValueWithNoSetterOptions>(
new string[] {
"Test" },
false,
false);
1113 act.Should().Throw<InvalidOperationException>()
1114 .Which.Message.Should().Be(
"Type CommandLine.Tests.Unit.Core.InstanceBuilderTests+ValueWithNoSetterOptions appears to be immutable, but no constructor found to accept values.");
1120 Action act = () => InvokeBuild<ValueWithNoSetterOptions>(
new string[] {
"--help" });
1122 act.Should().Throw<InvalidOperationException>()
1123 .Which.Message.Should().Be(
"Type CommandLine.Tests.Unit.Core.InstanceBuilderTests+ValueWithNoSetterOptions appears to be immutable, but no constructor found to accept values.");
1130 var optionNames =
new List<NameInfo>
1138 var result = InvokeBuild<Options_With_Group>(
1139 new[] {
"-v 10.42" });
1149 var optionNames1 =
new List<NameInfo>
1154 var optionNames2 =
new List<NameInfo>
1159 var expectedResult =
new[]
1166 var result = InvokeBuild<Options_With_Multiple_Groups>(
1167 new[] {
"-v 10.42" });
1174 [InlineData(
"-v",
"10.5",
"--option1",
"test1",
"--option2",
"test2")]
1175 [InlineData(
"-v",
"10.5",
"--option1",
"test1")]
1176 [InlineData(
"-v",
"10.5",
"--option2",
"test2")]
1180 var result = InvokeBuild<Options_With_Group>(args);
1190 var optionNames =
new List<NameInfo>
1198 var result = InvokeBuild<Simple_Options_With_Required_OptionGroup>(
new string[] {
"-x" });
1204 errors.Should().HaveCount(1);
1205 errors.Should().BeEquivalentTo(expectedResult);
1211 var expectedResult =
new[]
1218 var result = InvokeBuild<Simple_Options_With_OptionGroup_WithDefaultValue>(
new string[] {
"-x" });
1224 errors.Should().BeEquivalentTo(expectedResult);
1231 var result = InvokeBuild<Simple_Options_With_OptionGroup_WithOptionDefaultValue>(
new string[] {
"-x" });
1240 var expectedResult =
new[]
1247 var result = InvokeBuild<Simple_Options_With_OptionGroup_MutuallyExclusiveSet>(
new string[] {
"-x" });
1253 errors.Should().BeEquivalentTo(expectedResult);
1259 var expected =
new[] { 1, 2, 3 };
1260 var result = InvokeBuild<Options_With_Sequence>(
1261 new[] {
"--int-seq",
"1",
"2",
"--int-seq",
"3" },
1262 multiInstance:
true);
1267 #region custom types
1271 [InlineData(
new[] {
"-c",
"localhost:8080" },
"localhost", 8080)]
1277 var result = InvokeBuild<CustomStructOptions>(arguments);
1281 customValue.Server.Should().Be(expectedServer);
1282 customValue.Port.Should().Be(expectedPort);
1283 customValue.Input.Should().Be(arguments[1]);
1287 [InlineData(
new[] {
"-c",
"localhost:8080" },
"localhost", 8080)]
1293 var result = InvokeBuild<CustomClassOptions>(arguments);
1297 customValue.Server.Should().Be(expectedServer);
1298 customValue.Port.Should().Be(expectedPort);
1299 customValue.Input.Should().Be(arguments[1]);
1305 [
Value(0, MetaName =
"Test", Default = 0)]
1339 yield
return new object[] {
new string[] { },
new Immutable_Simple_Options(
null,
new int[] { },
default(
bool),
default(
long)) };
1340 yield
return new object[] {
new[] {
"--stringvalue=strval0" },
new Immutable_Simple_Options(
"strval0",
new int[] { },
default(
bool),
default(
long)) };
1341 yield
return new object[] {
new[] {
"-i",
"9",
"7",
"8" },
new Immutable_Simple_Options(
null,
new[] { 9, 7, 8 },
default(
bool),
default(
long)) };
1342 yield
return new object[] {
new[] {
"-x" },
new Immutable_Simple_Options(
null,
new int[] { },
true,
default(
long)) };
1343 yield
return new object[] {
new[] {
"9876543210" },
new Immutable_Simple_Options(
null,
new int[] { },
default(
bool), 9876543210L) };
1344 yield
return new object[] {
new[] {
"--stringvalue=strval0",
"-i",
"9",
"7",
"8",
"-x",
"9876543210" },
new Immutable_Simple_Options(
"strval0",
new[] { 9, 7, 8 },
true, 9876543210L) };
1351 yield
return new object[] {
new string[] { } } ;
1352 yield
return new object[] {
new [] {
"--stringvalue=strval0"}};
1353 yield
return new object[] {
new[] {
"-i",
"9",
"7",
"8" } };
1354 yield
return new object[] {
new[] {
"-x" }};
1355 yield
return new object[] {
new[] {
"9876543210" }};
1356 yield
return new object[] {
new[] {
"--stringvalue=strval0",
"-i",
"9",
"7",
"8",
"-x",
"9876543210" }};
1364 var guid0 = Guid.NewGuid();
1365 var guid1 = Guid.NewGuid();
1366 yield
return new object[] {
new[] {
"--txid", guid0.ToStringInvariant() },
new Options_With_Guid { TransactionId = guid0 } };
1367 yield
return new object[] {
new[] {
"--txid=" + guid1.ToStringInvariant() },
new Options_With_Guid { TransactionId = guid1 } };
1368 yield
return new object[] {
new[] {
"-t", guid0.ToStringInvariant() },
new Options_With_Guid { TransactionId = guid0 } };
1369 yield
return new object[] {
new[] {
"-t" + guid1.ToStringInvariant() },
new Options_With_Guid { TransactionId = guid1 } };
The Maybe type models an optional value. A value of type Maybe a either contains a value of type a (r...
static NameLookupResult Contains(string name, IEnumerable< OptionSpecification > specifications, StringComparer comparer)
static Func< IEnumerable< string >, IEnumerable< OptionSpecification >, Result< IEnumerable< Token >, Error > > ConfigureTokenizer(StringComparer nameComparer, bool ignoreUnknownArguments, bool enableDashDash)
static Result< IEnumerable< Token >, Error > Tokenize(IEnumerable< string > arguments, Func< string, NameLookupResult > nameLookup)
static Result< IEnumerable< Token >, Error > PreprocessDashDash(IEnumerable< string > arguments, Func< IEnumerable< string >, Result< IEnumerable< Token >, Error > > tokenizer)
Models an error generated when a user explicitly requests help.
Models an error generated when an invalid token is detected.
const string ErrorMessage
Models an error generated when a required option is required.
Models an error generated when an option lacks its value.
Models an error generated when a an option from another set is defined.
Models name information, used in CommandLine.Error instances.
static readonly NameInfo EmptyName
Represents an empty name information. Used when CommandLine.Error are tied to values,...
It contains a sequence of CommandLine.Error.
It contains an instance of type T with parsed values.
Models a parser result. When inherited by CommandLine.Parsed<T>, it contains an instance of type T w...
IEnumerable< Error > Errors
Gets the sequence of parsing errors. If there are no errors, then an empty IEnumerable is returned.
T Value
Gets the instance with parsed values. If one or more errors occures, default is returned.
Models an error generated when a sequence value lacks elements.
Models as error generated when exception is thrown at Property.SetValue.
void Options_In_Group_WithRequired_Does_Not_Generate_RequiredError()
void Should_not_parse_quoted_TimeSpan()
void Parse_int_sequence(string[] arguments, int[] expected)
void Breaking_min_constraint_in_string_sequence_as_value_generates_SequenceOutOfRangeError()
void Parse_without_auto_version_should_not_recognize_version_option(string[] arguments, ErrorType errorType)
void Parse_nullable_int(string[] arguments, int? expected)
void Omitting_names_assumes_identifier_as_long_name(string[] arguments, string expected)
void Parse_with_custom_version_option(string[] arguments, bool isVersion)
void Parse_double_value(string[] arguments, double expected)
static ParserResult< T > InvokeBuild< T >(string[] arguments, bool autoHelp=true, bool autoVersion=true, bool multiInstance=false)
static IEnumerable< object[]> ImmutableInstanceDataArgs
void Breaking_max_constraint_in_string_sequence_does_not_generate_SequenceOutOfRangeError()
void Parse_fsharp_option_int(string[] arguments, int expectedValue, bool expectedSome)
void Parse_long_sequence_with_separator(string[] arguments, long[] expected)
void Options_In_Group_With_No_Values_Generates_MissingGroupOptionError()
void Can_define_options_on_interface_properties(string[] arguments, string expected)
void Explicit_help_request_generates_help_requested_error()
void Parse_unknown_short_option_generates_UnknownOptionError()
void OptionClass_IsImmutable_HasNoCtor_HelpRequested()
void Specifying_options_two_or_more_times_with_short_options_generates_RepeatedOptionError(string[] arguments, int expected)
void Parse_without_auto_help_should_not_recognize_help_option(string[] arguments, ErrorType errorType)
void Options_In_Group_Do_Not_Allow_Mutually_Exclusive_Set()
void Specifying_options_two_or_more_times_with_long_options_generates_RepeatedOptionError(string[] arguments, int expected)
void Parse_string_sequence_with_only_max_constraint(string[] arguments, string[] expected)
void Breaking_required_constraint_generate_MissingRequiredOptionError(string[] arguments, int expected)
void Breaking_required_constraint_in_string_scalar_as_value_generates_MissingRequiredOptionError()
void Enforce_required_within_mutually_exclusive_set_only(string[] arguments, ParserResultType type, int expected)
void Specifying_options_two_or_more_times_with_mixed_short_long_options_generates_RepeatedOptionError(string[] arguments, int expected)
void Parse_default_bool_type_string_SetValueExceptionError()
void Parse_string_with_dashes_except_in_beginning(string[] arguments, string expected)
void Parse_option_with_exception_thrown_from_setter_generates_SetValueExceptionError()
void Can_define_options_on_explicit_interface_properties(string[] arguments, string expected)
void Parse_option_from_different_sets_generates_MutuallyExclusiveSetError()
void Breaking_min_constraint_in_string_sequence_generates_MissingValueOptionError()
static ParserResult< T > InvokeBuildEnumValuesCaseIgnore< T >(string[] arguments)
void Parse_utf8_string_correctly(string[] arguments, string expected)
void Options_In_Group_Use_Option_Default_Value_When_Available()
void Parse_negative_long_value(string[] arguments, long expected)
void Min_constraint_set_to_zero_throws_exception()
void Parse_enum_value_with_wrong_item_name_generates_BadFormatConversionError()
void Options_In_Group_Ignore_Option_Group_If_Option_Group_Name_Empty()
void Breaking_max_constraint_in_string_sequence_as_value_generates_SequenceOutOfRangeError()
void Parse_Guid(string[] arguments, Options_With_Guid expected)
void Parse_int_sequence_with_range(string[] arguments, int[] expected)
void Parse_enum_value_with_wrong_index_generates_BadFormatConversionError()
void Parse_string_scalar_with_required_constraint_as_value(string[] arguments, Options_With_Required_Set_To_True_For_Values expected)
void Parse_custom_class_type(string[] arguments, string expectedServer, int expectedPort)
void Parse_to_immutable_instance(string[] arguments, Immutable_Simple_Options expected)
void Parse_nullable_long(string[] arguments, long? expected)
void Wrong_range_in_sequence_generates_SequenceOutOfRangeError()
void Max_constraint_set_to_zero_throws_exception()
void Parse_enum_value_with_wrong_item_name_case_generates_BadFormatConversionError()
void Two_required_options_at_the_same_set_and_none_are_true()
void Parse_enum_value_ignore_case(string[] arguments, Colors expected)
void Min_and_max_constraint_set_to_zero_throws_exception()
void Parse_int_sequence_with_multi_instance()
static IEnumerable< object[]> GuidData
void Options_In_Group_With_No_Values_Generates_MissingGroupOptionErrors()
static IEnumerable< object[]> RequiredValueStringData
static ParserResult< T > InvokeBuildImmutable< T >(string[] arguments)
void Parse_with_custom_help_option(string[] arguments, bool isHelp)
void Omitting_required_option_generates_MissingRequiredOptionError()
void Parse_string_sequence_with_separator(string[] arguments, string[] expected)
void Parse_enum_value(string[] arguments, Colors expected)
void Two_required_options_at_the_same_set_and_both_are_true()
static IEnumerable< object[]> ScalarSequenceStringAdjacentData
void Parse_to_immutable_instance_with_Invalid_Ctor_Args(string[] arguments)
void Parse_unknown_long_option_generates_UnknownOptionError()
void OptionClass_IsImmutable_HasNoCtor()
void Parse_sequence_value_without_range_constraints(string[] arguments, long[] expected)
void Specifying_options_two_or_more_times_generates_RepeatedOptionError(string[] arguments, int expected)
void Parse_unknown_short_option_in_option_group_generates_UnknownOptionError()
void Parse_custom_struct_type(string[] arguments, string expectedServer, int expectedPort)
void Options_In_Group_With_Values_Does_Not_Generate_MissingGroupOptionError(params string[] args)
void Parse_values_partitioned_between_sequence_and_scalar()
void Parse_to_type_with_single_string_ctor_builds_up_correct_instance()
void Empty_set_options_allowed_with_mutually_exclusive_sets(string[] arguments, ParserResultType type, int expected)
void Breaking_equal_min_max_constraint_in_string_sequence_as_value_generates_SequenceOutOfRangeError()
void Double_dash_force_subsequent_arguments_as_values()
https://github.com/gsscoder/commandline/issues/31
static IEnumerable< object[]> ImmutableInstanceData
void Parse_fsharp_option_string(string[] arguments, string expectedValue, bool expectedSome)
void Parse_string_scalar_and_sequence_adjacent(string[] arguments, Options_With_Scalar_Value_And_Adjacent_SequenceString expected)
void Parse_string_sequence_with_only_min_constraint(string[] arguments, string[] expected)
static TypeInfo Create(Type current)
Models an error generated when an unknown option is detected.
ParserResultType
Discriminator enumeration of CommandLine.ParserResultType derivates.
ErrorType
Discriminator enumeration of CommandLine.Error derivates.