| 
  |
Sample 
    using System;
    using System.IO;
    using System.Xml;
    using NUnit.Framework;
    using NXUnit.Framework;
    [TestFixture]
    public class Sample
    {
        private XMLAssert xa;
        [SetUp]
        public void Init()
        {
            xa = XMLAssert.CreateInstance();
        }
        [Test]
        public void TestMethod()
        {
            // Init the xml input
            string s1 = "...";
            string s2 = "...";
            // Init the options for your purpose
            xa.IsOrderSensitive = false;
            // Assert two XML inputs are equal
            xa.AreEqual(s1, s2, "Assertion Failed!");
            // Compare two XML inputs and find all differences between them
            CompareResult r = xa.Compare(s1, s2);
            foreach (Diff d in r)
            {
                Console.WriteLine(d);
            }
            CompareResult another = xa.Compare(s1, s2);
            r.Add(another);
            for (int i = 0; i < r.Count; i++)
            {
                Console.WriteLine(r[i]);
            }
            if (r.AreEqual)
            {
                // They are equal
            }
            // Assert two XML declaration of the two XML inputs are equal
            xa.AreDeclareEqual(s1, s2, "Declarations are not equal");
            // Assert two document types of the two XML inputs are equal
            xa.AreDocTypeEqual(s1, s2, "DocTypes are not equal");
            // Assert the validity of an XML input
            XMLAssert.IsValid("...");
            XMLAssert.IsValidFile(@"C:\...");
            // Assert the evaluation of an XPath expression on an XML input will 
            // return the expected value
            xa.AreXpathEqual("<a/>", "/r/a[2]", s1, 
				"The xpath expression doesn't return <a/>");
            // Assert an XPath expression is exist for an XML input
            XMLAssert.XpathExist("//@b='c'", s1, 
				"The xml document doesn't have the xpath expression");
            // Assert an XML input is included by another one
            xa.IsIncluded(s1, s2, "The {0} is not included in {1}", s1, s2);
            // The Counter
            Assert.AreEqual(6, xa.Counter);
            // XMLInput can use in all the samples above
            xa.AreEqual(XMLInput.CreateFromString(s1), 
				XMLInput.CreateFromString(s2), "Assertion Failed!");
        }
    }
		
 | 
    |
Copyright© 2005, Brian Sun All rights reserved.  | 
  |