Skip to content

Commit eba8845

Browse files
author
Per Gårdebrink
committed
Make sure explicit interface implementations can be parsed
1 parent edbd8c2 commit eba8845

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace CommandLine.Tests.Fakes
2+
{
3+
class Options_With_Only_Explicit_Interface : IInterface_With_Two_Scalar_Options
4+
{
5+
bool IInterface_With_Two_Scalar_Options.Verbose { get; set; }
6+
7+
string IInterface_With_Two_Scalar_Options.InputFile { get; set; }
8+
}
9+
}

tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs

+14
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,20 @@ public void Specifying_options_two_or_more_times_with_mixed_short_long_options_g
787787
((NotParsed<Simple_Options>)result).Errors.Should().HaveCount(x => x == expected);
788788
}
789789

790+
[Theory]
791+
[InlineData(new[] { "--inputfile=file1.bin" }, "file1.bin")]
792+
[InlineData(new[] { "--inputfile", "file2.txt" }, "file2.txt")]
793+
public void Can_define_options_on_explicit_interface_properties(string[] arguments, string expected)
794+
{
795+
// Exercize system
796+
var result = InvokeBuild<Options_With_Only_Explicit_Interface>(
797+
arguments);
798+
799+
// Verify outcome
800+
expected.Should().BeEquivalentTo(((IInterface_With_Two_Scalar_Options)((Parsed<Options_With_Only_Explicit_Interface>)result).Value).InputFile);
801+
}
802+
803+
790804
[Theory]
791805
[InlineData(new[] { "--inputfile=file1.bin" }, "file1.bin")]
792806
[InlineData(new[] { "--inputfile", "file2.txt" }, "file2.txt")]

0 commit comments

Comments
 (0)