예제 #1
0
        public void AssertXslTransformResultsWorksWithStrings()
        {
            string xslt    = XsltTests.IDENTITY_TRANSFORM;
            string someXml = "<a><b>c</b><b/></a>";

            OldXmlAssert.XslTransformResults(xslt, someXml, someXml);
        }
예제 #2
0
        public void AssertStringEqualAndIdenticalToSelf()
        {
            string control = _xmlTrueTest;
            string test    = _xmlTrueTest;

            OldXmlAssert.XmlIdentical(control, test);
            OldXmlAssert.XmlEquals(control, test);
        }
예제 #3
0
        public void AssertDifferentStringsNotEqualNorIdentical()
        {
            string  control = "<assert>true</assert>";
            string  test    = "<assert>false</assert>";
            XmlDiff xmlDiff = new XmlDiff(control, test);

            OldXmlAssert.XmlNotIdentical(xmlDiff);
            OldXmlAssert.XmlNotEquals(xmlDiff);
        }
예제 #4
0
 [Test] public void AssertXPathEvaluatesToWorksConstantExpression()
 {
     OldXmlAssert.XPathEvaluatesTo("true()",
                                   MY_SOLAR_SYSTEM,
                                   "True");
     OldXmlAssert.XPathEvaluatesTo("false()",
                                   MY_SOLAR_SYSTEM,
                                   "False");
 }
예제 #5
0
        public void AssertXmlValidTrueForValidFile()
        {
            StreamReader reader = new StreamReader(ValidatorTests.ValidFile);

            try {
                OldXmlAssert.XmlValid(reader);
            } finally {
                reader.Close();
            }
        }
예제 #6
0
        public void AssertXslTransformResultsWorksWithXmlInput()
        {
            StreamReader xsl            = ValidatorTests.GetTestReader("animal.xsl");
            XmlInput     xslt           = new XmlInput(xsl);
            StreamReader xml            = ValidatorTests.GetTestReader("testAnimal.xml");
            XmlInput     xmlToTransform = new XmlInput(xml);
            XmlInput     expectedXml    = new XmlInput("<dog/>");

            OldXmlAssert.XslTransformResults(xslt, xmlToTransform, expectedXml);
        }
예제 #7
0
 [Test] public void AssertXPathExistsFailsForNonExistentXPath()
 {
     try {
         OldXmlAssert.XPathExists("//star[@name='alpha centauri']",
                                  MY_SOLAR_SYSTEM);
         Assert.Fail("Expected assertion failure");
     } catch (AssertionException e) {
         AvoidUnusedVariableCompilerWarning(e);
     }
 }
예제 #8
0
 public void XmlEqualsWithXmlDiffFail_WithDiffConfiguration(string optionalDesciption, string expectedMessage)
 {
     try
     {
         OldXmlAssert.XmlEquals(new XmlDiff(new XmlInput(_xmlTrueTest), new XmlInput(_xmlFalseTest), new DiffConfiguration(optionalDesciption)));
     }
     catch (AssertionException e)
     {
         Assert.AreEqual(true, e.Message.StartsWith(expectedMessage));
     }
 }
예제 #9
0
 public void XmlEqualsWithXmlDiffFail_WithNullOptionalDescription()
 {
     try
     {
         OldXmlAssert.XmlEquals(new XmlDiff(new XmlInput(_xmlTrueTest), new XmlInput(_xmlFalseTest), new DiffConfiguration(null)));
     }
     catch (AssertionException e)
     {
         Assert.AreEqual(true, e.Message.StartsWith("Xml does not match"));
     }
 }
예제 #10
0
        public void AssertXmlEqualsUsesOptionalDescription()
        {
            string description = "Another Optional Description";

            try {
                XmlDiff diff = new XmlDiff(new XmlInput("<a/>"), new XmlInput("<b/>"),
                                           new DiffConfiguration(description));
                OldXmlAssert.XmlEquals(diff);
            } catch (AssertionException e) {
                Assert.AreEqual(true, e.Message.StartsWith(description));
            }
        }
예제 #11
0
        public void AssertXmlValidFalseForInvalidFile()
        {
            StreamReader reader = new StreamReader(ValidatorTests.InvalidFile);

            try {
                OldXmlAssert.XmlValid(reader);
                Assert.Fail("Expected assertion failure");
            } catch (AssertionException e) {
                AvoidUnusedVariableCompilerWarning(e);
            } finally {
                reader.Close();
            }
        }
예제 #12
0
        public void AssertXslTransformResultsCatchesFalsePositive()
        {
            StreamReader xsl               = ValidatorTests.GetTestReader("animal.xsl");
            XmlInput     xslt              = new XmlInput(xsl);
            StreamReader xml               = ValidatorTests.GetTestReader("testAnimal.xml");
            XmlInput     xmlToTransform    = new XmlInput(xml);
            XmlInput     expectedXml       = new XmlInput("<cat/>");
            bool         exceptionExpected = true;

            try {
                OldXmlAssert.XslTransformResults(xslt, xmlToTransform, expectedXml);
                exceptionExpected = false;
                Assert.Fail("Expected dog not cat!");
            } catch (AssertionException e) {
                AvoidUnusedVariableCompilerWarning(e);
                if (!exceptionExpected)
                {
                    throw e;
                }
            }
        }
예제 #13
0
 public void XmlEqualsWithXmlDiffFail()
 {
     OldXmlAssert.XmlEquals(new XmlDiff(new XmlInput(_xmlTrueTest), new XmlInput(_xmlFalseTest)));
 }
예제 #14
0
 public void XmlEqualsWithXmlDiff()
 {
     OldXmlAssert.XmlEquals(new XmlDiff(_xmlTrueTest, _xmlTrueTest));
 }
예제 #15
0
 public void XmlEqualsWithXmlInput()
 {
     OldXmlAssert.XmlEquals(new XmlInput(_xmlTrueTest), new XmlInput(_xmlTrueTest));
 }
예제 #16
0
 public void XmlEqualsWithStringFail()
 {
     OldXmlAssert.XmlEquals(_xmlTrueTest, _xmlFalseTest);
 }
예제 #17
0
 public void XmlEqualsWithTextReaderFail()
 {
     OldXmlAssert.XmlEquals(new StringReader(_xmlTrueTest), new StringReader(_xmlFalseTest));
 }
예제 #18
0
 [Test] public void AssertXPathExistsWorksForExistentXPath()
 {
     OldXmlAssert.XPathExists("//planet[@name='Earth']",
                              MY_SOLAR_SYSTEM);
 }
예제 #19
0
 [Test] public void AssertXPathEvaluatesToWorksForNonMatchingExpression()
 {
     OldXmlAssert.XPathEvaluatesTo("//planet[@position='4']/@supportsLife",
                                   MY_SOLAR_SYSTEM,
                                   "");
 }