public static void Deserialize_InvalidDictionaryXml_IgnoresInvalid() { string xml = @" <CollectionObject> <DictionaryValue> <Element> <Key>a</Key> <Value>1</Value> </Element> <Element> <Key>b</Key> </Element> <Element> <Value>3</Value> </Element> <Element> </Element> <Element> <Key>e</Key> <Value>5</Value> </Element> </DictionaryValue> </CollectionObject>"; CollectionObject co = XmlConvert.DeserializeObject <CollectionObject>(xml); Assert.Equal(2, co.DictionaryValue.Count); }
public static void Deserialize_EmptyCollectionXml_CreatesEmptyCollection() { string xml = @" <CollectionObject> <CollectionValue> </CollectionValue> </CollectionObject>"; CollectionObject co = XmlConvert.DeserializeObject <CollectionObject>(xml); Assert.Equal(0, co.CollectionValue.Count); }
public override bool Equals(object obj) { CollectionObject co = (CollectionObject)obj; if (co == null) { return(false); } if (CollectionValue == null && co.CollectionValue == null && ListValue == null && co.ListValue == null && DictionaryValue == null && co.DictionaryValue == null) { return(true); } return (CollectionValue != null && CollectionValue.Count.Equals(co.CollectionValue.Count) && ListValue != null && ListValue.Count.Equals(co.ListValue.Count) && DictionaryValue != null && DictionaryValue.Count.Equals(co.DictionaryValue.Count)); }
public AdvancedObject(PrimitiveObject po, CollectionObject co, EmbeddedObject eo) { PrimitiveObjectValue = po; CollectionObjectValue = co; EmbeddedObjectValue = eo; }
public static void SerializeDeserialize_CollectionObject_Success() { CollectionObject co = CreateCollectionObject(); SerializeDeserializeObject_Equal_Success(co, XmlConvertOptions.None); }