public void TestTitlesOuterHtml()
        {
            Dictionary <string, string> AssetDic = new Dictionary <string, string> ()
            {
                {
                    "HtmlDoc001",
                    "<title>HtmlDoc001</title>"
                },
                {
                    "HtmlDoc002",
                    "<title>HtmlDoc002</title>"
                },
                {
                    "HtmlDoc003",
                    "<title>HtmlDoc003</title>"
                },
                {
                    "HtmlDoc004",
                    "<title>HtmlDoc004</title>"
                },
                {
                    "HtmlDoc005",
                    "<title>HtmlDoc005</title>"
                }
            };

            MacroscopeDataExtractorXpaths DataExtractor = new MacroscopeDataExtractorXpaths(Size: 1);

            DataExtractor.SetXpath(
                Slot: 0,
                XpathLabel: "TestTitlesOuterHtml",
                XpathString: "//title",
                ExtractorType: MacroscopeConstants.DataExtractorType.OUTERHTML
                );

            DataExtractor.SetActiveInactive(
                Slot: 0,
                State: MacroscopeConstants.ActiveInactive.ACTIVE
                );

            foreach (string HtmlDocKey in this.HtmlDocs.Keys)
            {
                string Html = this.HtmlDocs[HtmlDocKey];

                List <KeyValuePair <string,  string> > ResultList = DataExtractor.AnalyzeHtml(Html: Html);

                DebugMsg(string.Format("HtmlDocKey: {0} :: Value: {1}", HtmlDocKey, ResultList[0].Value));

                Assert.IsNotEmpty(ResultList, "WHOOPS!");

                Assert.AreEqual(AssetDic[HtmlDocKey], ResultList[0].Value);
            }
        }
Beispiel #2
0
        public void TestTitlesInnerText()
        {
            Dictionary <string, string> AssetDic = new Dictionary <string, string>();

            AssetDic.Add("SEOMacroscope.src.MacroscopeDataExtractor.t.HtmlDocs.HtmlDoc001.html", "HtmlDoc001");
            AssetDic.Add("SEOMacroscope.src.MacroscopeDataExtractor.t.HtmlDocs.HtmlDoc002.html", "HtmlDoc002");
            AssetDic.Add("SEOMacroscope.src.MacroscopeDataExtractor.t.HtmlDocs.HtmlDoc003.html", "HtmlDoc003");
            AssetDic.Add("SEOMacroscope.src.MacroscopeDataExtractor.t.HtmlDocs.HtmlDoc004.html", "HtmlDoc004");
            AssetDic.Add("SEOMacroscope.src.MacroscopeDataExtractor.t.HtmlDocs.HtmlDoc005.html", "HtmlDoc005");

            MacroscopeDataExtractorXpaths DataExtractor = new MacroscopeDataExtractorXpaths(Size: 1);

            DataExtractor.SetXpath(
                Slot: 0,
                XpathLabel: "TestTitlesInnerText",
                XpathString: "//title",
                ExtractorType: MacroscopeConstants.DataExtractorType.INNERTEXT
                );

            DataExtractor.SetActiveInactive(
                Slot: 0,
                State: MacroscopeConstants.ActiveInactive.ACTIVE
                );

            foreach (string HtmlDocKey in this.HtmlDocs.Keys)
            {
                string Html = this.HtmlDocs[HtmlDocKey];

                List <KeyValuePair <string, string> > ResultList = DataExtractor.AnalyzeHtml(Html: Html);

                DebugMsg(string.Format("HtmlDocKey: {0} :: Value: {1}", HtmlDocKey, ResultList[0].Value));

                Assert.IsNotEmpty(ResultList, "WHOOPS!");

                Assert.AreEqual(AssetDic[HtmlDocKey], ResultList[0].Value);
            }
        }