Example #1
0
 public XmlDiff(XmlInput control, XmlInput test,
                DiffConfiguration diffConfiguration)
 {
     _diffConfiguration = diffConfiguration;
     controlInput       = control;
     testInput          = test;
 }
Example #2
0
        public static void XPathEvaluatesTo(string anXPathExpression, XmlInput inXml,
                                            string expectedValue)
        {
            XPath xpath = new XPath(anXPathExpression);

            NUnit.Framework.Assert.AreEqual(expectedValue, xpath.EvaluateXPath(inXml));
        }
Example #3
0
        public static void XslTransformResults(XmlInput xslTransform, XmlInput xmlToTransform, XmlInput expectedResult)
        {
            Xslt      xslt   = new Xslt(xslTransform);
            XmlOutput output = xslt.Transform(xmlToTransform);

            XmlEquals(expectedResult, output.AsXml());
        }
Example #4
0
        private XPathNavigator GetNavigator(XmlInput forXmlInput)
        {
            XPathDocument xpathDocument =
                new XPathDocument(forXmlInput.CreateXmlReader());

            return(xpathDocument.CreateNavigator());
        }
Example #5
0
        public static void AssertXPathEvaluatesTo(string anXPathExpression, XmlInput inXml,
                                                  string expectedValue)
        {
            XPath xpath = new XPath(anXPathExpression);

            AssertEquals(expectedValue, xpath.EvaluateXPath(inXml));
        }
Example #6
0
 public string EvaluateXPath(XmlInput forXmlInput)
 {
     XPathNavigator xpathNavigator = GetNavigator(forXmlInput);
     XPathExpression xPathExpression = xpathNavigator.Compile(_xPathExpression);
     if (xPathExpression.ReturnType == XPathResultType.NodeSet) {
         return EvaluateXPath(xpathNavigator);
     } else {
         return xpathNavigator.Evaluate(xPathExpression).ToString();
     }
 }
Example #7
0
        public XmlDiff(XmlInput control, XmlInput test,
					   DiffConfiguration diffConfiguration)
        {
            _diffConfiguration =  diffConfiguration;
            _controlReader = CreateXmlReader(control);
            if (control.Equals(test)) {
                _testReader = _controlReader;
            } else {
                _testReader = CreateXmlReader(test);
            }
        }
 [Test] public void StreamInputTranslatesToXmlReader() {
     MemoryStream stream = new MemoryStream();
     StreamWriter writer = new StreamWriter(stream, Encoding.Default);
     writer.WriteLine(INPUT);
     writer.Flush();
     stream.Seek(0, SeekOrigin.Begin);
     XmlInput input = new XmlInput(stream);
     string actual = ReadOuterXml(input.CreateXmlReader());
     try {
         Assert.AreEqual(_expected, actual);
     } finally {
         writer.Close();
     }
 }
Example #9
0
 private XmlReader CreateXmlReader(XmlInput forInput) {
     XmlReader xmlReader = forInput.CreateXmlReader();
 	
     if (xmlReader is XmlTextReader) {
         ((XmlTextReader) xmlReader ).WhitespaceHandling = _diffConfiguration.WhitespaceHandling;
     }
     
     if (_diffConfiguration.UseValidatingParser) {
         XmlValidatingReader validatingReader = new XmlValidatingReader(xmlReader);
         return validatingReader;
     }
     
     return xmlReader;
 }
Example #10
0
 public XmlDiff(XmlInput control, XmlInput test,
                DiffConfiguration diffConfiguration)
 {
     _diffConfiguration = diffConfiguration;
     _controlReader     = CreateXmlReader(control);
     if (control.Equals(test))
     {
         _testReader = _controlReader;
     }
     else
     {
         _testReader = CreateXmlReader(test);
     }
 }
Example #11
0
        public string EvaluateXPath(XmlInput forXmlInput)
        {
            XPathNavigator  xpathNavigator  = GetNavigator(forXmlInput);
            XPathExpression xPathExpression = xpathNavigator.Compile(_xPathExpression);

            if (xPathExpression.ReturnType == XPathResultType.NodeSet)
            {
                return(EvaluateXPath(xpathNavigator));
            }
            else
            {
                return(xpathNavigator.Evaluate(xPathExpression).ToString());
            }
        }
Example #12
0
        private XmlReader CreateXmlReader(XmlInput forInput)
        {
            XmlReader xmlReader = forInput.CreateXmlReader();

            if (xmlReader is XmlTextReader)
            {
                ((XmlTextReader)xmlReader).WhitespaceHandling = _diffConfiguration.WhitespaceHandling;
            }

            if (_diffConfiguration.UseValidatingParser)
            {
                XmlValidatingReader validatingReader = new XmlValidatingReader(xmlReader);
                return(validatingReader);
            }

            return(xmlReader);
        }
Example #13
0
        private XmlReader CreateXmlReader(XmlInput forInput)
        {
            XmlReader xmlReader = forInput.CreateXmlReader();

            if (xmlReader is XmlTextReader)
            {
                ((XmlTextReader)xmlReader).WhitespaceHandling = _diffConfiguration.WhitespaceHandling;
            }

            if (_diffConfiguration.UseValidatingParser)
            {
                var settings = new XmlReaderSettings();
                settings.ValidationType = ValidationType.Schema | ValidationType.DTD;
                var validatingReader = XmlReader.Create(xmlReader, settings);
                return(validatingReader);
            }

            return(xmlReader);
        }
Example #14
0
 public static void AssertXmlValid(XmlInput xmlInput)
 {
     Validator validator = new Validator(xmlInput);
     AssertXmlValid(validator);
 }
Example #15
0
 public static void AssertXmlEquals(XmlInput controlInput, XmlInput testInput)
 {
     AssertXmlEquals(new XmlDiff(controlInput, testInput));
 }
Example #16
0
 public static void AssertXPathExists(string anXPathExpression, XmlInput inXml)
 {
     XPath xpath = new XPath(anXPathExpression);
     AssertEquals(true, xpath.XPathExists(inXml));
 }
Example #17
0
 private XPathNodeIterator GetNodeIterator(XmlInput forXmlInput)
 {
     XPathNavigator xpathNavigator = GetNavigator(forXmlInput);
     return xpathNavigator.Select(_xPathExpression);
 }
Example #18
0
        public bool XPathExists(XmlInput forInput)
        {
            XPathNodeIterator iterator = GetNodeIterator(forInput);

            return(iterator.Count > 0);
        }
Example #19
0
 public static void XmlEquals(XmlInput controlInput, XmlInput testInput)
 {
     XmlEquals(new XmlDiff(controlInput, testInput));
 }
Example #20
0
 public void TextReaderInputTranslatesToXmlReader()
 {
     XmlInput input = new XmlInput(new StringReader(INPUT));
     string actual = ReadOuterXml(input.CreateXmlReader());
     Assertion.AssertEquals(_expected, actual);
 }
Example #21
0
 public Xslt(XmlInput xsltInput, XmlResolver xsltResolver, Evidence evidence)
 {
     _xsltInput = xsltInput;
     _xsltResolver = xsltResolver;
     _evidence = evidence;
 }
 [Test] public void EqualsCopyOfSelf() {
     XmlInput input = new XmlInput(INPUT);
     Assert.AreEqual(new XmlInput(INPUT), input);
 }
Example #23
0
        private XPathNodeIterator GetNodeIterator(XmlInput forXmlInput)
        {
            XPathNavigator xpathNavigator = GetNavigator(forXmlInput);

            return(xpathNavigator.Select(_xPathExpression));
        }
Example #24
0
 public void EqualsSelf()
 {
     XmlInput input = new XmlInput(INPUT);
     Assertion.AssertEquals(input, input);
 }
Example #25
0
 public void NotEqualsADifferentClass()
 {
     XmlInput input = new XmlInput(INPUT);
     Assertion.AssertEquals(false, input.Equals(INPUT));
 }
Example #26
0
 public Xslt(XmlInput xsltInput)
     : this(xsltInput, null, null)
 {
 }
Example #27
0
        public static void XPathExists(string anXPathExpression, XmlInput inXml)
        {
            XPath xpath = new XPath(anXPathExpression);

            NUnit.Framework.Assert.AreEqual(true, xpath.XPathExists(inXml));
        }
Example #28
0
 public XmlOutput Transform(XmlInput someXml)
 {
     return Transform(someXml, null);
 }
Example #29
0
 public static void XmlIdentical(XmlInput controlInput, XmlInput testInput)
 {
     XmlIdentical(new XmlDiff(controlInput, testInput));
 }
Example #30
0
 public XmlOutput Transform(XmlInput someXml, XsltArgumentList xsltArgs)
 {
     return Transform(someXml.CreateXmlReader(), null, xsltArgs);
 }
Example #31
0
 private XPathNavigator GetNavigator(XmlInput forXmlInput)
 {
     XPathDocument xpathDocument =
         new XPathDocument(forXmlInput.CreateXmlReader());
     return xpathDocument.CreateNavigator();
 }
 [Test] public void EqualsSelf() {
     XmlInput input = new XmlInput(INPUT);
     Assert.AreEqual(input, input);
 }
Example #33
0
        public static void AssertXPathEvaluatesTo(string anXPathExpression, XmlInput inXml,
												  string expectedValue)
        {
            XPath xpath = new XPath(anXPathExpression);
            AssertEquals(expectedValue, xpath.EvaluateXPath(inXml));
        }
Example #34
0
 public XmlDiff(XmlInput control, XmlInput test)
     : this(control, test, new DiffConfiguration())
 {
 }
Example #35
0
 public static void AssertXslTransformResults(XmlInput xslTransform, XmlInput xmlToTransform, XmlInput expectedResult)
 {
     Xslt xslt = new Xslt(xslTransform);
     XmlOutput output = xslt.Transform(xmlToTransform);
     AssertXmlEquals(expectedResult, output.AsXml());
 }
 public void AssertXslTransformResultsCatchesFalsePositive()
 {
     StreamReader xsl = GetStreamReader(".\\..\\tests\\etc\\animal.xsl");
     XmlInput xslt = new XmlInput(xsl);
     StreamReader xml = GetStreamReader(".\\..\\tests\\etc\\testAnimal.xml");
     XmlInput xmlToTransform = new XmlInput(xml);
     XmlInput expectedXml = new XmlInput("<cat/>");
     bool exceptionExpected = true;
     try {
         XmlAssertion.AssertXslTransformResults(xslt, xmlToTransform, expectedXml);
         exceptionExpected = false;
         Assertion.Fail("Expected dog not cat!");
     } catch (AssertionException e) {
         AvoidUnusedVariableCompilerWarning(e);
         if (!exceptionExpected) {
             throw e;
         }
     }
 }
Example #37
0
 public static void AssertXmlIdentical(XmlInput controlInput, XmlInput testInput)
 {
     AssertXmlIdentical(new XmlDiff(controlInput, testInput));
 }
 public void AssertXslTransformResultsWorksWithXmlInput()
 {
     StreamReader xsl = GetStreamReader(".\\..\\tests\\etc\\animal.xsl");
     XmlInput xslt = new XmlInput(xsl);
     StreamReader xml = GetStreamReader(".\\..\\tests\\etc\\testAnimal.xml");
     XmlInput xmlToTransform = new XmlInput(xml);
     XmlInput expectedXml = new XmlInput("<dog/>");
     XmlAssertion.AssertXslTransformResults(xslt, xmlToTransform, expectedXml);
 }
Example #39
0
 public void EqualsCopyOfSelf()
 {
     XmlInput input = new XmlInput(INPUT);
     Assertion.AssertEquals(new XmlInput(INPUT), input);
 }
Example #40
0
        public static void AssertXPathExists(string anXPathExpression, XmlInput inXml)
        {
            XPath xpath = new XPath(anXPathExpression);

            AssertEquals(true, xpath.XPathExists(inXml));
        }
Example #41
0
 public void HashCodeEqualsHashCodeOfInput()
 {
     XmlInput input = new XmlInput(INPUT);
     Assertion.AssertEquals(INPUT.GetHashCode(), input.GetHashCode());
 }
Example #42
0
 public Xslt(XmlInput xsltInput, XmlResolver xsltResolver, Evidence evidence)
 {
     _xsltInput    = xsltInput;
     _xsltResolver = xsltResolver;
     _evidence     = evidence;
 }
Example #43
0
 public void NotEqualsNull()
 {
     XmlInput input = new XmlInput(INPUT);
     Assertion.AssertEquals(false, input.Equals(null));
 }
Example #44
0
 public Validator(XmlInput input) :
     this(input.CreateXmlReader())
 {
 }
Example #45
0
        public static void XmlValid(XmlInput xmlInput)
        {
            Validator validator = new Validator(xmlInput);

            XmlValid(validator);
        }
Example #46
0
 public XmlDiff(XmlInput control, XmlInput test)
     : this(control, test, new DiffConfiguration())
 {
 }
Example #47
0
 public XmlOutput Transform(XmlInput someXml)
 {
     return(Transform(someXml, null));
 }
Example #48
0
 public XmlOutput Transform(XmlInput someXml, XsltArgumentList xsltArgs)
 {
     return(Transform(someXml.CreateXmlReader(), null, xsltArgs));
 }
Example #49
0
 public Xslt(XmlInput xsltInput)
     : this(xsltInput, null, null)
 {
 }
Example #50
0
 public bool XPathExists(XmlInput forInput)
 {
     XPathNodeIterator iterator = GetNodeIterator(forInput);
     return (iterator.Count > 0);
 }
Example #51
0
 public Validator(XmlInput input)
     : this(input.CreateXmlReader())
 {
 }
 [Test] public void HashCodeEqualsHashCodeOfCopy() {
     XmlInput input = new XmlInput(INPUT);
     Assert.AreEqual(new XmlInput(INPUT).GetHashCode(), input.GetHashCode());
 }