-
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.
Fixed references resolution bugs during deserialization
- Loading branch information
1 parent
bc308e1
commit b8fb4d4
Showing
3 changed files
with
147 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
48 changes: 48 additions & 0 deletions
48
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue358Tests_Extended.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,48 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Support; | ||
using FluentAssertions; | ||
using JetBrains.Annotations; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue358Tests_Extended | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var serializer = new ConfigurationContainer().EnableParameterizedContentWithPropertyAssignments() | ||
.EnableReferences() | ||
.Create() | ||
.ForTesting(); | ||
|
||
var length = new length(11); | ||
var instance = new vector(length, length); | ||
|
||
var cycled = serializer.Cycle(instance); | ||
cycled.L1.Should().BeSameAs(cycled.L2); | ||
} | ||
|
||
class length | ||
{ | ||
public length(int value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public int Value { [UsedImplicitly] get; } | ||
} | ||
|
||
class vector | ||
{ | ||
public vector(length l1, length l2) | ||
{ | ||
L1 = l1; | ||
L2 = l2; | ||
} | ||
|
||
public length L1 { get; } | ||
public length L2 { get; } | ||
} | ||
} | ||
} |
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; } | ||
} | ||
} | ||
} |