-
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.
Added non-generic equivalent for
AddMigration
(#484)
- Loading branch information
1 parent
087c5b9
commit 5e5c10c
Showing
3 changed files
with
130 additions
and
2 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
93 changes: 93 additions & 0 deletions
93
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue483Tests.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,93 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using FluentAssertions; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue483Tests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
//// Write legacy XML | ||
//var rootInitialVersion = new Root { Identifier = Guid.NewGuid() }; | ||
//var someClass1 = new SomeClass { Id = 1, SomeString = "String1" }; | ||
//var someClass2 = new SomeClass { Id = 2, SomeString = "String2" }; | ||
//var children = new List<Node>(); | ||
//for (var i = 1; i < 10; i++) | ||
// children.Add(new Node | ||
// { | ||
// Id = i, | ||
// Blubb = i % 2 == 0 ? someClass1 : someClass2 | ||
// }); | ||
//rootInitialVersion.Children = children; | ||
|
||
//var serializer = new ConfigurationContainer() | ||
// .ConfigureType<SomeClass>() | ||
// .EnableReferences(s => s.Id) | ||
// .Create(); | ||
//var initialXml = serializer.Serialize(new XmlWriterSettings { Indent = true }, rootInitialVersion); | ||
|
||
var initialXml = @"<?xml version='1.0' encoding='utf-8'?> | ||
<Root xmlns='clr-namespace:ExtendedXmlSerializer.Tests.ReportedIssues;assembly=ExtendedXmlSerializer.Tests.ReportedIssues'> | ||
<Identifier>391047bb-21a7-46cb-b49c-6b9353305d09</Identifier> | ||
<Children> | ||
<Capacity>16</Capacity> | ||
<Node> | ||
<Id>1</Id> | ||
<Blubb Id='2'> | ||
<SomeString>String2</SomeString> | ||
</Blubb> | ||
</Node> | ||
<Node> | ||
<Id>2</Id> | ||
<Blubb Id='1'> | ||
<SomeString>String1</SomeString> | ||
</Blubb> | ||
</Node> | ||
<Node> | ||
<Id>3</Id> | ||
<Blubb xmlns:exs='https://extendedxmlserializer.github.io/v2' exs:entity='2' /> | ||
</Node> | ||
<Node> | ||
<Id>4</Id> | ||
<Blubb xmlns:exs='https://extendedxmlserializer.github.io/v2' exs:entity='1' /> | ||
</Node> | ||
<Node> | ||
<Id>5</Id> | ||
<Blubb xmlns:exs='https://extendedxmlserializer.github.io/v2' exs:entity='2' /> | ||
</Node> | ||
<Node> | ||
<Id>6</Id> | ||
<Blubb xmlns:exs='https://extendedxmlserializer.github.io/v2' exs:entity='1' /> | ||
</Node> | ||
<Node> | ||
<Id>7</Id> | ||
<Blubb xmlns:exs='https://extendedxmlserializer.github.io/v2' exs:entity='2' /> | ||
</Node> | ||
<Node> | ||
<Id>8</Id> | ||
<Blubb xmlns:exs='https://extendedxmlserializer.github.io/v2' exs:entity='1' /> | ||
</Node> | ||
<Node> | ||
<Id>9</Id> | ||
<Blubb xmlns:exs='https://extendedxmlserializer.github.io/v2' exs:entity='2' /> | ||
</Node> | ||
</Children> | ||
</Root>"; | ||
|
||
new ConfigurationContainer().Type<SomeClass>() | ||
.EnableReferences(s => s.Id) | ||
.As<ITypeConfiguration>() | ||
.AddMigration(new SomeClassMigrations()) | ||
.Create() | ||
.Deserialize<Root>(initialXml) | ||
.Children | ||
.Select(x => x.Blubb.RenamedProperty) | ||
.Take(4) | ||
.Should() | ||
.Equal("String2", "String1", "String2", "String1"); | ||
} | ||
} | ||
} |