From 924721eef89c06a330b1aaec6c48792f0a53d269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20G=C3=A5rdebrink?= Date: Sun, 8 Mar 2020 13:17:54 +0100 Subject: [PATCH] Add test to make sure parser can detect explicit interface implementations --- tests/CommandLine.Tests/Unit/Issue591ests.cs | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/CommandLine.Tests/Unit/Issue591ests.cs diff --git a/tests/CommandLine.Tests/Unit/Issue591ests.cs b/tests/CommandLine.Tests/Unit/Issue591ests.cs new file mode 100644 index 00000000..3888a705 --- /dev/null +++ b/tests/CommandLine.Tests/Unit/Issue591ests.cs @@ -0,0 +1,29 @@ +using System.Linq; +using CommandLine.Tests.Fakes; +using CommandLine.Text; +using FluentAssertions; +using Xunit; +using Xunit.Abstractions; + +//Issue #591 +//When options class is only having explicit interface declarations, it should be detected as mutable. + +namespace CommandLine.Tests.Unit +{ + public class Issue591ests + { + [Fact] + public void Parse_option_with_only_explicit_interface_implementation() + { + string actual = string.Empty; + + var arguments = new[] { "--inputfile", "file2.txt" }; + var result = Parser.Default.ParseArguments(arguments); + result.WithParsed(options => { + actual = ((IInterface_With_Two_Scalar_Options)options).InputFile; + }); + + actual.Should().Be("file2.txt"); + } + } +}