Skip to content

Commit d9efdac

Browse files
committed
added test for invalid situation where options class has properties with no setter and no valid constructor
1 parent ebc6f37 commit d9efdac

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,21 @@ public void Parse_TimeSpan()
11331133
// Teardown
11341134
}
11351135

1136+
[Fact]
1137+
public void OptionClass_IsImmutable_HasNoCtor()
1138+
{
1139+
Action act = () => InvokeBuild<ValueWithNoSetterOptions>(new string[] { "Test" }, false, false);
1140+
1141+
act.Should().Throw<InvalidOperationException>();
1142+
}
1143+
1144+
private class ValueWithNoSetterOptions
1145+
{
1146+
[Value(0, MetaName = "Test", Default = 0)]
1147+
public int TestValue { get; }
1148+
}
1149+
1150+
11361151
public static IEnumerable<object[]> RequiredValueStringData
11371152
{
11381153
get

0 commit comments

Comments
 (0)