Ejemplo n.º 1
0
        public void AttributesTest()
        {
            XElement element = new XElement("element");

            Assert.IsFalse(element.AllAttributes().Any());

            XAttribute attribute = new XAttribute("attribute", "value");

            element = new XElement("element", attribute);
            Assert.IsTrue(object.ReferenceEquals(element.AllAttributes().Single(), attribute));

            XDocument document = new XDocument(element);

            Assert.IsTrue(object.ReferenceEquals(document.AllAttributes().Single(), attribute));

            element.Add(element);
            Assert.AreEqual(2, element.AllAttributes().Count());
            Assert.AreEqual(2, document.AllAttributes().Count());
        }