Exemplo n.º 1
0
        public void DuplicateIdInEntityAttached()
        {
            v.Detach();

            XmlElement a1 = doc.CreateElement("anchor");

            a1.SetAttribute("id", "id1");

            XmlEntityReference xer = doc.CreateEntityReference("test");

            // no errors at this point (not added to doc yet)
            Assert.AreEqual(0, v.InvalidNodes.AllErrors.Length);

            doc.DocumentElement.AppendChild(a1);
            doc.DocumentElement.AppendChild(xer);

            v = new ValidationManager();
            v.Attach(doc, null);

            Assert.AreEqual(2, v.InvalidNodes.AllErrors.Length, "Expected duplicate ids");

            doc.DocumentElement.RemoveChild(a1);

            Assert.AreEqual(0, v.InvalidNodes.AllErrors.Length, "Errors remain after removing duplicate");
        }