-
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 namespace resolution bug in migration extension (#518)
- Loading branch information
1 parent
84dc8d5
commit 86c603a
Showing
4 changed files
with
138 additions
and
14 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
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
57 changes: 57 additions & 0 deletions
57
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue517Tests.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,57 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Shared.Issue517; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Support; | ||
using FluentAssertions; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Xml.Linq; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue517Tests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var instance = new Class1 { obj = new Class2() }; | ||
|
||
var sut = new ConfigurationContainer().Type<Class1>() | ||
.AddMigration(new EmptyMigration()) | ||
.Create() | ||
.ForTesting(); | ||
|
||
sut.Cycle(instance).Should().BeEquivalentTo(instance); | ||
} | ||
|
||
[Fact] | ||
public void VerifyAdditional() | ||
{ | ||
var container = new Shared.Issue517.ContainerNameSpace.Container(); | ||
for (int i = 0; i < 1; i++) | ||
{ | ||
container.Childrens.Add(new Shared.Issue517.ItemNameSpace.Item()); | ||
} | ||
|
||
IConfigurationContainer config = new ConfigurationContainer(); | ||
config.Type<Shared.Issue517.ContainerNameSpace.Container>().AddMigration(new EmptyMigration()); | ||
var serializer = config.Create().ForTesting(); | ||
|
||
serializer.Cycle(container).Should().BeEquivalentTo(container); | ||
|
||
} | ||
|
||
public class EmptyMigration : IEnumerable<Action<XElement>> | ||
{ | ||
public IEnumerator<Action<XElement>> GetEnumerator() | ||
{ | ||
yield return x => {}; //Do nothing | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} | ||
|
||
class Class2 : Interface1 {} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue517/Class1.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,33 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues.Shared.Issue517 | ||
{ | ||
class ItemContainer | ||
{ | ||
|
||
public List<Class1> Items { get; set; } = new List<Class1>(); | ||
|
||
} | ||
|
||
class Class1 | ||
{ | ||
|
||
public Interface1 obj { get; set; } | ||
} | ||
|
||
interface Interface1 { } | ||
|
||
namespace ContainerNameSpace | ||
{ | ||
class Container | ||
{ | ||
public List<ItemNameSpace.Item> Childrens { get; set; } = new List<ItemNameSpace.Item>(); | ||
} | ||
} | ||
|
||
namespace ItemNameSpace | ||
{ | ||
class Item { } | ||
} | ||
|
||
} |