-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating reference object after deserialization/activation.
- Loading branch information
1 parent
b51263c
commit 7e2d9b4
Showing
2 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue418Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Support; | ||
using FluentAssertions; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue418Tests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var b1 = new Book(); | ||
var b2 = new Book(); | ||
|
||
var allBooks = new[] {b1, b2,}; | ||
|
||
var fs = new BookStore() | ||
{ | ||
AllBooks = allBooks, | ||
Genres = new[] | ||
{ | ||
new Genre | ||
{ | ||
Books = allBooks, | ||
}, | ||
new Genre | ||
{ | ||
Books = allBooks, | ||
}, | ||
} | ||
}; | ||
|
||
var serializer = new ConfigurationContainer().Type<Book[]>() | ||
.EnableReferences() | ||
.Create() | ||
.ForTesting(); | ||
|
||
var cycled = serializer.Cycle(fs); | ||
|
||
cycled.AllBooks.Should().BeSameAs(cycled.Genres.ElementAt(0).Books); | ||
cycled.AllBooks.Should().BeSameAs(cycled.Genres.ElementAt(1).Books); | ||
} | ||
|
||
class BookStore | ||
{ | ||
public IEnumerable<Book> AllBooks { get; set; } | ||
public IEnumerable<Genre> Genres { get; set; } | ||
} | ||
|
||
class Book {} | ||
|
||
class Genre | ||
{ | ||
public IEnumerable<Book> Books { get; set; } | ||
} | ||
} | ||
} |