Example #1
0
        public void RssXmlSchemaValidatorIsValidXmlTest()
        {
            RssXmlSchemaValidator target = new RssXmlSchemaValidator();
            string validXml = RssToolkitUnitTest.Utility.RssUtility.RssXml;

            Assembly assbly = Assembly.Load("RssToolkit");
            Stream   strm1  = assbly.GetManifestResourceStream(RssToolkit.Constants.Rss20Xsd);
            Stream   strm2  = assbly.GetManifestResourceStream(RssToolkit.Constants.Rss20Xsd);


            target.ValidXmlDoc(validXml, new XmlTextReader(strm1));
            Assert.IsTrue(target.IsValidXml, "RssToolkit.Rss.RssXmlSchemaValidator.IsValidXml was not set correctly.");


            target.ValidXmlDoc(invalidXml, new XmlTextReader(strm2));
            Assert.IsFalse(target.IsValidXml, "RssToolkit.Rss.RssXmlSchemaValidator.IsValidXml was not set correctly.");
        }
Example #2
0
        public void RssXmlSchemaValidatorValidXmlDocTest()
        {
            RssXmlSchemaValidator target = new RssXmlSchemaValidator();
            string validXml = RssToolkitUnitTest.Utility.RssUtility.RssXml;

            Assembly assbly = Assembly.Load("RssToolkit");
            Stream   strm1  = assbly.GetManifestResourceStream(RssToolkit.Constants.Rss20Xsd);
            Stream   strm2  = assbly.GetManifestResourceStream(RssToolkit.Constants.Rss20Xsd);


            target.ValidXmlDoc(validXml, new XmlTextReader(strm1));
            Assert.IsTrue(target.IsValidXml, "RssToolkit.Rss.RssXmlSchemaValidator.IsValidXml was not set correctly.");


            target.ValidXmlDoc(invalidXml, new XmlTextReader(strm2));
            Assert.IsFalse(target.IsValidXml, "RssToolkit.Rss.RssXmlSchemaValidator.IsValidXml was not set correctly.");

            Assert.AreEqual("The element 'rss' has invalid child element 'channl'. List of possible elements expected: 'channel'.", target.ValidationError);
        }