Beispiel #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);
        }
Beispiel #2
0
        public static void SerializeDeserialize_AttributeName_Success()
        {
            AttributeNamedObject ano     = new AttributeNamedObject("name");
            XElement             element = XmlConvert.SerializeXElement(ano);

            Assert.Equal("AttributeIdentifier", element.Name);
            Assert.Equal("name", element.Element("CustomElementIdentifier").Value);

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