Created
September 5, 2011 18:46
-
-
Save danstuken/1195650 to your computer and use it in GitHub Desktop.
Simple Cyclical JsonFx Test
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
namespace JsonFx.Xml | |
{ | |
using System.Xml.Serialization; | |
using Resolvers; | |
using Serialization; | |
using Xunit; | |
public class XmlReaderTests | |
{ | |
public class Person | |
{ | |
public string Name { get; set; } | |
public Person Father { get; set; } | |
public Person Mother { get; set; } | |
[XmlAttribute("theNickname")] | |
public string Nickname { get; set; } | |
public Person[] Children { get; set; } | |
} | |
private const string TraitName = "XML"; | |
private const string TraitValue = "Reader"; | |
[Fact] | |
[Trait(TraitName, TraitValue)] | |
public void TestCompleteCircle() | |
{ | |
var input = new Person | |
{ | |
Name = "John, Jr.", | |
Nickname = "Junior", | |
Father = new Person | |
{ | |
Name = "John, Sr.", | |
Nickname = "Jack" | |
}, | |
Mother = new Person | |
{ | |
Name = "Sally", | |
Nickname = "Sal" | |
} | |
}; | |
var producedXml = new XmlWriter(new DataWriterSettings(new XmlResolverStrategy())).Write(input); | |
var person = new XmlReader(new DataReaderSettings(new XmlResolverStrategy())).Read<Person>(producedXml); | |
Assert.Equal(input, person); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment