-
Notifications
You must be signed in to change notification settings - Fork 479
Expand file tree
/
Copy pathIssue777Tests.cs
More file actions
42 lines (35 loc) · 1.05 KB
/
Issue777Tests.cs
File metadata and controls
42 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using FluentAssertions;
using Xunit;
// Issue #777
// Record types should be usable as immutable options types.
namespace CommandLine.Tests.Unit
{
#if NET5_0_OR_GREATER
public class Issue777Tests
{
[Fact]
public void Immutable_record_types_should_work()
{
var arguments = new[] { "--option1=test", "--option2=5", "--option3" };
var result = Parser.Default
.ParseArguments<Options>(arguments);
Assert.Empty(result.Errors);
Assert.Equal(ParserResultType.Parsed, result.Tag);
result.WithParsed(options =>
{
options.Option1.Should().Be("test");
options.Option2.Should().Be(5);
options.Option3.Should().Be(true);
});
}
private record Options(
[property: Option]
string Option1,
[property: Option]
int Option2,
[property: Option]
bool Option3
);
}
#endif
}