public void Can_Deserialize_Attribute_Using_Exact_Name_Defined_In_DeserializeAs_Attribute() { const string @namespace = "http://restsharp.org"; var ns = XNamespace.Get(@namespace); var doc = new XDocument( new XElement( ns + "response", new XAttribute(ns + "attribute-value", "711"), "random value" ) ); var expected = new NodeWithAttributeAndValue { AttributeValue = "711" }; var xml = new XmlDeserializer { Namespace = @namespace }; var output = xml.Deserialize <NodeWithAttributeAndValue>(new RestResponse { Content = doc.ToString() }); Assert.Equal(expected.AttributeValue, output.AttributeValue); }
public void Can_Deserialize_Attribute_Using_Exact_Name_Defined_In_DeserializeAs_Attribute() { var content = @"<response attribute-value=""711""></response>"; var expected = new NodeWithAttributeAndValue { AttributeValue = "711" }; var xml = new XmlDeserializer(); var output = xml.Deserialize <NodeWithAttributeAndValue>(new RestResponse { Content = content }) !; Assert.Equal(expected.AttributeValue, output.AttributeValue); }