Ejemplo n.º 1
0
        public void RssCodeGeneratorGenerateCodeDomTreeTest()
        {
            RssDocument  rssDefinition   = RssUtility.GetRssDocumentFromUrl();
            string       namespaceName   = "test";
            string       outputLanguage  = "cs";
            string       classNamePrefix = "Test";
            StringWriter outputCode      = new StringWriter();
            bool         useBaseClass    = true;
            // generate the CodeDom tree
            // get the CodeDom provider for the language
            CodeDomProvider provider = CodeDomProvider.CreateProvider(outputLanguage);
            CodeCompileUnit unit     = new CodeCompileUnit();

            RssToolkit.Rss.CodeGeneration.RssCodeGenerator.GenerateCodeDomTree(rssDefinition, namespaceName, classNamePrefix, unit, useBaseClass);

            // generate source
            CodeGeneratorOptions options = new CodeGeneratorOptions();

            options.BlankLinesBetweenMembers = true;
            options.BracingStyle             = "Block";
            options.ElseOnClosing            = false;
            options.IndentString             = "    ";

            provider.GenerateCodeFromCompileUnit(unit, outputCode, options);

            TestConditions(outputCode.ToString());
        }
Ejemplo n.º 2
0
        public void RssDocumentToDataSetTest()
        {
            RssDocument rss     = RssUtility.GetRssDocumentFromUrl();
            DataSet     dataSet = rss.ToDataSet();

            Assert.IsTrue(dataSet.Tables["item"].Rows.Count > 0, "RssToolkit.Rss.RssDocument.ToDataSet did not return the expected value.");
        }
Ejemplo n.º 3
0
        public void RssDocumentUrlTest()
        {
            RssDocument target = RssUtility.GetRssDocumentFromUrl();
            string      val    = RssUtility.RssUrl;

            RssToolkitUnitTest.RssToolkit_Rss_RssDocumentAccessor accessor = new RssToolkitUnitTest.RssToolkit_Rss_RssDocumentAccessor(target);
            Assert.AreEqual(val, accessor.Url, "RssToolkit.Rss.RssDocument.Url was not set correctly.");
        }
Ejemplo n.º 4
0
        public void RssDocumentVersionTest()
        {
            RssDocument target = RssUtility.GetRssDocumentFromUrl();

            Assert.AreEqual("2.0", target.Version, "RssToolkit.Rss.RssDocument.Version was not set correctly.");
            string val = "1.0";

            target.Version = val;
            Assert.AreEqual(val, target.Version, "RssToolkit.Rss.RssDocument.Version was not set correctly.");
        }
Ejemplo n.º 5
0
        public void RssDocumentSelectItemsTest()
        {
            RssDocument target = RssUtility.GetRssDocumentFromUrl();
            IEnumerable actual;

            actual = target.SelectItems();
            System.Data.DataView view = (System.Data.DataView)target.SelectItems();
            Assert.IsTrue(actual.GetEnumerator().MoveNext(), "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
            Assert.IsTrue(view.Table.Rows.Count > 0, "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
        }
Ejemplo n.º 6
0
        public void RssDocumentSelectItemsTest2()
        {
            RssDocument target       = RssUtility.GetRssDocumentFromUrl();
            int         maxItems     = 10;
            bool        reverseOrder = true;
            IEnumerable actual       = target.SelectItems(maxItems, reverseOrder);

            System.Data.DataView view = (System.Data.DataView)target.SelectItems(maxItems, reverseOrder);
            Assert.IsTrue(actual.GetEnumerator().MoveNext(), "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
            Assert.IsTrue(view.Table.Rows.Count == 10, "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
        }
Ejemplo n.º 7
0
        public void RssCodeGeneratorGenerateCodeTest()
        {
            RssDocument  rssDefinition   = RssUtility.GetRssDocumentFromUrl();
            string       outputLanguage  = "cs";
            string       namespaceName   = "test";
            string       classNamePrefix = "Test";
            StringWriter outputCode      = new StringWriter();
            bool         useBaseClass    = true;

            RssToolkit.Rss.CodeGeneration.RssCodeGenerator.GenerateCode(rssDefinition, outputLanguage, namespaceName, classNamePrefix, outputCode, useBaseClass);
            TestConditions(outputCode.ToString());
        }
Ejemplo n.º 8
0
        public void RssDocumentToXmlTest()
        {
            RssDocument rss = RssUtility.GetRssDocumentFromUrl();
            string      xml = rss.ToXml(DocumentType.Rss);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            Assert.IsTrue(doc.SelectNodes("/rss/channel/item").Count > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rss/channel/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rss/channel/item/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");

            xml = rss.ToXml(DocumentType.Atom);
            doc.LoadXml(xml);
            Assert.IsTrue(doc.SelectNodes("/feed/entry").Count > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/feed/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/feed/entry/summary").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");

            xml = rss.ToXml(DocumentType.Rdf);
            doc.LoadXml(xml);
            Assert.IsTrue(doc.SelectNodes("/rdf/item").Count > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rdf/channel/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rdf/item/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
        }
Ejemplo n.º 9
0
        public void RssDocumentLoadRssFromXmlTest()
        {
            RssDocument actual = RssUtility.GetRssDocumentFromXml();

            Assert.IsTrue(actual.Channel.Items.Count > 0, "RssToolkit.Rss.RssDocument.Load did not return the expected value.");
        }