Esempio n. 1
0
 public XmlDiff(XmlInput control, XmlInput test,
                DiffConfiguration diffConfiguration)
 {
     _diffConfiguration = diffConfiguration;
     controlInput       = control;
     testInput          = test;
 }
Esempio n. 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));
        }
Esempio n. 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());
        }
Esempio n. 4
0
        private XPathNavigator GetNavigator(XmlInput forXmlInput)
        {
            XPathDocument xpathDocument =
                new XPathDocument(forXmlInput.CreateXmlReader());

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

            AssertEquals(expectedValue, xpath.EvaluateXPath(inXml));
        }
Esempio n. 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();
     }
 }
Esempio n. 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);
            }
        }
Esempio n. 8
0
 [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();
     }
 }
Esempio n. 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;
 }
Esempio n. 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);
     }
 }
Esempio n. 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());
            }
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 14
0
 public static void AssertXmlValid(XmlInput xmlInput)
 {
     Validator validator = new Validator(xmlInput);
     AssertXmlValid(validator);
 }
Esempio n. 15
0
 public static void AssertXmlEquals(XmlInput controlInput, XmlInput testInput)
 {
     AssertXmlEquals(new XmlDiff(controlInput, testInput));
 }
Esempio n. 16
0
 public static void AssertXPathExists(string anXPathExpression, XmlInput inXml)
 {
     XPath xpath = new XPath(anXPathExpression);
     AssertEquals(true, xpath.XPathExists(inXml));
 }
Esempio n. 17
0
 private XPathNodeIterator GetNodeIterator(XmlInput forXmlInput)
 {
     XPathNavigator xpathNavigator = GetNavigator(forXmlInput);
     return xpathNavigator.Select(_xPathExpression);
 }
Esempio n. 18
0
        public bool XPathExists(XmlInput forInput)
        {
            XPathNodeIterator iterator = GetNodeIterator(forInput);

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

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

            NUnit.Framework.Assert.AreEqual(true, xpath.XPathExists(inXml));
        }
Esempio n. 28
0
 public XmlOutput Transform(XmlInput someXml)
 {
     return Transform(someXml, null);
 }
Esempio n. 29
0
 public static void XmlIdentical(XmlInput controlInput, XmlInput testInput)
 {
     XmlIdentical(new XmlDiff(controlInput, testInput));
 }
Esempio n. 30
0
 public XmlOutput Transform(XmlInput someXml, XsltArgumentList xsltArgs)
 {
     return Transform(someXml.CreateXmlReader(), null, xsltArgs);
 }
Esempio n. 31
0
 private XPathNavigator GetNavigator(XmlInput forXmlInput)
 {
     XPathDocument xpathDocument =
         new XPathDocument(forXmlInput.CreateXmlReader());
     return xpathDocument.CreateNavigator();
 }
Esempio n. 32
0
 [Test] public void EqualsSelf() {
     XmlInput input = new XmlInput(INPUT);
     Assert.AreEqual(input, input);
 }
Esempio n. 33
0
        public static void AssertXPathEvaluatesTo(string anXPathExpression, XmlInput inXml,
												  string expectedValue)
        {
            XPath xpath = new XPath(anXPathExpression);
            AssertEquals(expectedValue, xpath.EvaluateXPath(inXml));
        }
Esempio n. 34
0
 public XmlDiff(XmlInput control, XmlInput test)
     : this(control, test, new DiffConfiguration())
 {
 }
Esempio n. 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());
 }
Esempio n. 36
0
 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;
         }
     }
 }
Esempio n. 37
0
 public static void AssertXmlIdentical(XmlInput controlInput, XmlInput testInput)
 {
     AssertXmlIdentical(new XmlDiff(controlInput, testInput));
 }
Esempio n. 38
0
 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);
 }
Esempio n. 39
0
 public void EqualsCopyOfSelf()
 {
     XmlInput input = new XmlInput(INPUT);
     Assertion.AssertEquals(new XmlInput(INPUT), input);
 }
Esempio n. 40
0
        public static void AssertXPathExists(string anXPathExpression, XmlInput inXml)
        {
            XPath xpath = new XPath(anXPathExpression);

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

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