-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathIssue397Tests.cs
48 lines (42 loc) · 1.53 KB
/
Issue397Tests.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
using ExtendedXmlSerializer.Configuration;
using ExtendedXmlSerializer.Tests.ReportedIssues.Support;
using FluentAssertions;
using System;
using Xunit;
namespace ExtendedXmlSerializer.Tests.ReportedIssues
{
public sealed class Issue397Tests
{
[Fact]
public void Verify()
{
var serializer = new ConfigurationContainer().UseAutoFormatting()
.UseOptimizedNamespaces()
.EnableImplicitTyping(typeof(MainDTO),
typeof(SubDTO), typeof(SubSubDTO))
.Type<SubSubDTO>()
.EnableReferences(definition => definition.Id)
.Create()
.ForTesting();
var instance = new MainDTO();
var cycled = serializer.Cycle(instance);
cycled.Sub1.SubSub1.Should().BeSameAs(cycled.Sub2.SubSub1);
cycled.Sub1.SubSub1.Should().BeSameAs(cycled.Sub3.SubSub1);
}
public class MainDTO
{
public SubDTO Sub1 { get; set; } = new SubDTO();
public SubDTO Sub2 { get; set; } = new SubDTO();
public SubDTO Sub3 { get; set; } = new SubDTO();
}
public class SubDTO
{
public SubSubDTO SubSub1 { get; set; } = SubSubDTO.NullObject;
}
public class SubSubDTO
{
public static SubSubDTO NullObject { get; } = new SubSubDTO();
public string Id { get; set; } = Guid.NewGuid().ToString();
}
}
}