public void WriteIntegerValueForPropertyOfTypeDouble() { XamlSchemaContext xsc = new XamlSchemaContext(); XamlObjectWriter ow = new XamlObjectWriter(xsc); XamlType simpleElementXT = xsc.GetXamlType(typeof(ElementWithSimpleProperties)); ow.WriteStartObject(simpleElementXT); ow.WriteStartMember(simpleElementXT.GetMember("Double")); ow.WriteValue(23); ow.WriteEndMember(); ow.WriteEndObject(); ElementWithSimpleProperties simpleElement = (ElementWithSimpleProperties)(ow.Result); if (23 != simpleElement.Double) { throw new Exception("simpleElement.Double==" + simpleElement.Double + " ; expected 23. Int32 didn't work."); } }
public void WriteStringValueForPropertyOfTypeString() { XamlSchemaContext xsc = new XamlSchemaContext(); XamlObjectWriter ow = new XamlObjectWriter(xsc); XamlType simpleElementXT = xsc.GetXamlType(typeof(ElementWithSimpleProperties)); ow.WriteStartObject(simpleElementXT); ow.WriteStartMember(simpleElementXT.GetMember("String")); ow.WriteValue("23.5"); ow.WriteEndMember(); ow.WriteEndObject(); ElementWithSimpleProperties simpleElement = (ElementWithSimpleProperties)(ow.Result); if ("23.5" != simpleElement.String) { throw new Exception("simpleElement.String==\"" + simpleElement.String + "\" ; expected \"23.5\""); } }