public void IdentityXmlTest() { XmlComparer target = new XmlComparer(); target.AddIdentify(new AttributeIdentify("A", "name")); XmlCompareResults result = target.Compare(@"<Persons> <A name=""1"" value=""a1"" /> <A name=""2"" value=""a2"" /> <A name=""3"" value=""a3"" /> </Persons>", @"<Persons > <A name=""1"" value=""a1"" /> <A name=""2"" value=""a2"" /> <A name=""3"" value=""a3"" /> </Persons>"); Assert.IsTrue(result.IsValid); result = target.Compare(@"<Persons> <A name=""1"" value=""a1"" /> <A name=""2"" value=""a1"" /> <A name=""3"" value=""a3"" /> </Persons>", @"<Persons > <A name=""1"" value=""a1"" /> <A name=""2"" value=""a2"" /> <A name=""3"" value=""a3"" /> </Persons>"); Assert.IsTrue(!result.IsValid); target = new XmlComparer(); target.AddIdentify(new AttributeIdentify("A", "name", "urn:schemas-microsoft-com:windows:storage:mapping:CS")); result = target.Compare(@"<Persons xmlns=""urn:schemas-microsoft-com:windows:storage:mapping:CS"" xmlns:store=""china""> <A name=""1"" value=""a1"" /> <A name=""2"" value=""a2"" /> <A name=""3"" value=""a3"" /> </Persons>", @"<Persons xmlns=""urn:schemas-microsoft-com:windows:storage:mapping:CS"" xmlns:store=""china""> <A name=""1"" value=""a1"" /> <A name=""2"" value=""a2"" /> <A name=""3"" value=""a3"" /> </Persons>"); Assert.IsTrue(result.IsValid); result = target.Compare(@"<Persons xmlns=""urn:schemas-microsoft-com:windows:storage:mapping:CS"" xmlns:store=""china""> <A name=""1"" value=""a1"" /> <A name=""2"" value=""a1"" /> <A name=""3"" value=""a3"" /> </Persons>", @"<Persons xmlns=""urn:schemas-microsoft-com:windows:storage:mapping:CS"" xmlns:store=""china""> <A name=""1"" value=""a1"" /> <A name=""2"" value=""a2"" /> <A name=""3"" value=""a3"" /> </Persons>"); Assert.IsTrue(!result.IsValid); }
public void XmlCompareResultsTest() { XmlComparer target = new XmlComparer(); target.AddIdentify(new AttributeIdentify("A", "name")); XmlCompareResults result = target.Compare(@"<Persons> <A name=""1"" value=""a1"" /> <A name=""2"" value=""a1"" /> <A name=""3"" value=""a3"" /> </Persons>", @"<Persons > <A name=""1"" value=""a1"" /> <A name=""2"" value=""a2"" /> <A name=""3"" value=""a3"" /> </Persons>"); Assert.IsTrue(!result.IsValid); Assert.AreEqual(1, result.Errors.Count()); }