Created
July 25, 2011 11:37
-
-
Save HEskandari/1103958 to your computer and use it in GitHub Desktop.
Failing test when deserializing xml content
This file contains hidden or 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
[TestFixture] | |
public class DefaultDecoderTests | |
{ | |
[Test] | |
public void XmlAttributes_Are_Not_Converted_To_Elements() | |
{ | |
var customerRaw = @"<Customer Mode=""Add""> | |
<CustomerNo>02121V</CustomerNo> | |
</Customer>"; | |
var xmlSerializer = new XmlSerializer(typeof (Customer)); | |
var reader = new StringReader(customerRaw); | |
var customer = (Customer)xmlSerializer.Deserialize(reader); | |
var writer = new XmlWriter(); | |
var serialized = writer.Write(customer); | |
Assert.NotNull(serialized); | |
Assert.That(serialized, Is.StringContaining("Mode=\"Add\"")); | |
} | |
[Serializable] | |
public class Customer | |
{ | |
[XmlAttribute] | |
public string Mode { get; set; } | |
[XmlElement] | |
public string CustomerNo { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment