Ejemplo n.º 1
0
        public static void SerializeDeserialize_CustomNamedCollection_Success()
        {
            CustomNameCollectionObject cnco = new CustomNameCollectionObject(new Collection <string>
            {
                "1",
                "2",
                "3"
            },
                                                                             new Dictionary <string, string>
            {
                { "a", "1" },
                { "b", "2" },
                { "c", "3" },
            });

            XElement element = XmlConvert.SerializeXElement(cnco);

            XElement collectionElement = element.Element("CollectionValue");

            Assert.Equal(3, collectionElement.Elements("CollectionElement").Count());

            XElement        dictionaryElement  = element.Element("DictionaryValue");
            List <XElement> dictionaryElements = new List <XElement>(dictionaryElement.Elements("DictionaryElement"));

            Assert.Equal(3, dictionaryElements.Count);

            Assert.Equal(3, dictionaryElements.Elements("DictionaryKey").Count());
            Assert.Equal(3, dictionaryElements.Elements("DictionaryKey").Count());

            XmlConvertTests.SerializeDeserializeObject_Equal_Success(cnco, XmlConvertOptions.None);
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            CustomNameCollectionObject co = (CustomNameCollectionObject)obj;

            if (co == null)
            {
                return(false);
            }

            if (CollectionValue == null && co.CollectionValue == null &&
                DictionaryValue == null && co.DictionaryValue == null)
            {
                return(true);
            }

            return
                (CollectionValue != null && CollectionValue.Count.Equals(co.CollectionValue.Count) &&
                 DictionaryValue != null && DictionaryValue.Count.Equals(co.DictionaryValue.Count));
        }
Ejemplo n.º 3
0
        public static void SerializeDeserialize_CustomNamedCollection_Success()
        {
            CustomNameCollectionObject cnco = new CustomNameCollectionObject(new Collection<string>
            {
                "1",
                "2",
                "3"
            },
			new Dictionary<string, string>
            {
                { "a", "1" },
                { "b", "2" },
                { "c", "3" },
            });

            XElement element = XmlConvert.SerializeXElement(cnco);

            XElement collectionElement = element.Element("CollectionValue");
            Assert.Equal(3, collectionElement.Elements("CollectionElement").Count());

            XElement dictionaryElement = element.Element("DictionaryValue");
            List<XElement> dictionaryElements = new List<XElement>(dictionaryElement.Elements("DictionaryElement"));
            Assert.Equal(3, dictionaryElements.Count);
			
            Assert.Equal(3, dictionaryElements.Elements("DictionaryKey").Count());
            Assert.Equal(3, dictionaryElements.Elements("DictionaryKey").Count());

            XmlConvertTests.SerializeDeserializeObject_Equal_Success(cnco, XmlConvertOptions.None);
        }