Skip to content

Commit 2896eac

Browse files
author
Per Gårdebrink
committed
Make sure explicit interface implementations can be parsed
1 parent 8c88e9a commit 2896eac

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+
}

Diff for: tests/CommandLine.Tests/Unit/Core/InstanceBuilderTests.cs

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

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

0 commit comments

Comments
 (0)