public XmlDiff(XmlInput control, XmlInput test, DiffConfiguration diffConfiguration) { _diffConfiguration = diffConfiguration; controlInput = control; testInput = test; }
public static void XPathEvaluatesTo(string anXPathExpression, XmlInput inXml, string expectedValue) { XPath xpath = new XPath(anXPathExpression); NUnit.Framework.Assert.AreEqual(expectedValue, xpath.EvaluateXPath(inXml)); }
public static void XslTransformResults(XmlInput xslTransform, XmlInput xmlToTransform, XmlInput expectedResult) { Xslt xslt = new Xslt(xslTransform); XmlOutput output = xslt.Transform(xmlToTransform); XmlEquals(expectedResult, output.AsXml()); }
private XPathNavigator GetNavigator(XmlInput forXmlInput) { XPathDocument xpathDocument = new XPathDocument(forXmlInput.CreateXmlReader()); return(xpathDocument.CreateNavigator()); }
public static void AssertXPathEvaluatesTo(string anXPathExpression, XmlInput inXml, string expectedValue) { XPath xpath = new XPath(anXPathExpression); AssertEquals(expectedValue, xpath.EvaluateXPath(inXml)); }
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(); } }
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(); } }
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; }
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()); } }
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); }
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); }
public static void AssertXmlValid(XmlInput xmlInput) { Validator validator = new Validator(xmlInput); AssertXmlValid(validator); }
public static void AssertXmlEquals(XmlInput controlInput, XmlInput testInput) { AssertXmlEquals(new XmlDiff(controlInput, testInput)); }
public static void AssertXPathExists(string anXPathExpression, XmlInput inXml) { XPath xpath = new XPath(anXPathExpression); AssertEquals(true, xpath.XPathExists(inXml)); }
private XPathNodeIterator GetNodeIterator(XmlInput forXmlInput) { XPathNavigator xpathNavigator = GetNavigator(forXmlInput); return xpathNavigator.Select(_xPathExpression); }
public bool XPathExists(XmlInput forInput) { XPathNodeIterator iterator = GetNodeIterator(forInput); return(iterator.Count > 0); }
public static void XmlEquals(XmlInput controlInput, XmlInput testInput) { XmlEquals(new XmlDiff(controlInput, testInput)); }
public void TextReaderInputTranslatesToXmlReader() { XmlInput input = new XmlInput(new StringReader(INPUT)); string actual = ReadOuterXml(input.CreateXmlReader()); Assertion.AssertEquals(_expected, actual); }
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); }
private XPathNodeIterator GetNodeIterator(XmlInput forXmlInput) { XPathNavigator xpathNavigator = GetNavigator(forXmlInput); return(xpathNavigator.Select(_xPathExpression)); }
public void EqualsSelf() { XmlInput input = new XmlInput(INPUT); Assertion.AssertEquals(input, input); }
public void NotEqualsADifferentClass() { XmlInput input = new XmlInput(INPUT); Assertion.AssertEquals(false, input.Equals(INPUT)); }
public Xslt(XmlInput xsltInput) : this(xsltInput, null, null) { }
public static void XPathExists(string anXPathExpression, XmlInput inXml) { XPath xpath = new XPath(anXPathExpression); NUnit.Framework.Assert.AreEqual(true, xpath.XPathExists(inXml)); }
public XmlOutput Transform(XmlInput someXml) { return Transform(someXml, null); }
public static void XmlIdentical(XmlInput controlInput, XmlInput testInput) { XmlIdentical(new XmlDiff(controlInput, testInput)); }
public XmlOutput Transform(XmlInput someXml, XsltArgumentList xsltArgs) { return Transform(someXml.CreateXmlReader(), null, xsltArgs); }
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); }
public XmlDiff(XmlInput control, XmlInput test) : this(control, test, new DiffConfiguration()) { }
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; } } }
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); }
public void EqualsCopyOfSelf() { XmlInput input = new XmlInput(INPUT); Assertion.AssertEquals(new XmlInput(INPUT), input); }
public void HashCodeEqualsHashCodeOfInput() { XmlInput input = new XmlInput(INPUT); Assertion.AssertEquals(INPUT.GetHashCode(), input.GetHashCode()); }
public void NotEqualsNull() { XmlInput input = new XmlInput(INPUT); Assertion.AssertEquals(false, input.Equals(null)); }
public Validator(XmlInput input) : this(input.CreateXmlReader()) { }
public static void XmlValid(XmlInput xmlInput) { Validator validator = new Validator(xmlInput); XmlValid(validator); }
public XmlOutput Transform(XmlInput someXml) { return(Transform(someXml, null)); }
public XmlOutput Transform(XmlInput someXml, XsltArgumentList xsltArgs) { return(Transform(someXml.CreateXmlReader(), null, xsltArgs)); }
public bool XPathExists(XmlInput forInput) { XPathNodeIterator iterator = GetNodeIterator(forInput); return (iterator.Count > 0); }
[Test] public void HashCodeEqualsHashCodeOfCopy() { XmlInput input = new XmlInput(INPUT); Assert.AreEqual(new XmlInput(INPUT).GetHashCode(), input.GetHashCode()); }