Exemple #1
0
        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);
        }
Exemple #2
0
        public static void Deserialize_EmptyCollectionXml_CreatesEmptyCollection()
        {
            string xml = @"
<CollectionObject>
    <CollectionValue>
    </CollectionValue>
</CollectionObject>";

            CollectionObject co = XmlConvert.DeserializeObject <CollectionObject>(xml);

            Assert.Equal(0, co.CollectionValue.Count);
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 public AdvancedObject(PrimitiveObject po, CollectionObject co, EmbeddedObject eo)
 {
     PrimitiveObjectValue  = po;
     CollectionObjectValue = co;
     EmbeddedObjectValue   = eo;
 }
Exemple #5
0
 public AdvancedObject(PrimitiveObject po, CollectionObject co, EmbeddedObject eo)
 {
     PrimitiveObjectValue = po;
     CollectionObjectValue = co;
     EmbeddedObjectValue = eo;
 }
Exemple #6
0
        public static void SerializeDeserialize_CollectionObject_Success()
        {
            CollectionObject co = CreateCollectionObject();

            SerializeDeserializeObject_Equal_Success(co, XmlConvertOptions.None);
        }