forked from VerifyTests/Verify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SortedPropertiesTests.cs
98 lines (86 loc) · 1.86 KB
/
SortedPropertiesTests.cs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using Newtonsoft.Json;
#region SortProperties
static class ModuleInitializer
{
[ModuleInitializer]
public static void Init() =>
VerifierSettings.SortPropertiesAlphabetically();
}
#endregion
[UsesVerify]
public class SortedPropertiesTests
{
#region SortPropertiesUsage
[Fact]
public Task Alphabetically()
{
var person = new Person
{
Id = Guid.NewGuid(),
Title = Title.Mr,
GivenNames = "John",
FamilyName = "Smith",
Spouse = "Jill",
Children = new()
{
"Sam",
"Mary"
},
Address = new()
{
Street = "1 Puddle Lane",
Country = "USA"
}
};
return Verify(person);
}
#endregion
[Fact]
public Task DoesNotAffectTypeName()
{
var person = new Person
{
Id = Guid.NewGuid(),
Title = Title.Mr,
GivenNames = "John",
FamilyName = "Smith",
Spouse = "Jill",
Children = new()
{
"Sam",
"Mary"
},
Address = new()
{
Street = "1 Puddle Lane",
Country = "USA"
}
};
return Verify(person)
.AddExtraSettings(
_ => _.TypeNameHandling = TypeNameHandling.All);
}
}
#pragma warning disable CS8618
public class Person
{
public string? GivenNames;
public string FamilyName;
public string Spouse;
public Address Address;
public List<string> Children;
public Title Title;
public Guid Id;
public DateTimeOffset Dob;
}
public class Address
{
public string Street;
public string Suburb;
public string Country;
}
public enum Title
{
Mr,
Mrs
}