public void TestDuplicate() { const string StartUrl = "https://nazuke.github.io/SEOMacroscope/"; const string DupeUrl = "https://nazuke.github.io/SEOMacroscope/index.html"; MacroscopeJobMaster JobMaster = new MacroscopeJobMaster( JobRunTimeMode: MacroscopeConstants.RunTimeMode.LIVE, TaskController: this ); MacroscopeDocumentCollection DocCollection = new MacroscopeDocumentCollection(JobMaster: JobMaster); Dictionary <string, Boolean> CrossCheckList = MacroscopeLevenshteinAnalysis.GetCrossCheckList(Capacity: DocCollection.CountDocuments()); MacroscopeDocument msDoc = DocCollection.CreateDocument(StartUrl); MacroscopeDocument msDocDifferent = DocCollection.CreateDocument(DupeUrl); msDoc.Execute(); msDocDifferent.Execute(); DocCollection.AddDocument(msDoc); DocCollection.AddDocument(msDocDifferent); DebugMsg(string.Format("msDoc: {0}", msDoc.GetStatusCode())); DebugMsg(string.Format("msDocDifferent: {0}", msDocDifferent.GetStatusCode())); for (int i = 1; i <= 100; i++) { MacroscopeLevenshteinAnalysis LevenshteinAnalysis = new MacroscopeLevenshteinAnalysis( msDoc: msDoc, SizeDifference: 64, Threshold: 16, CrossCheckList: CrossCheckList ); Dictionary <MacroscopeDocument, int> DocList = LevenshteinAnalysis.AnalyzeDocCollection(DocCollection: DocCollection); DebugMsg(string.Format("DocList: {0}", DocList.Count)); foreach (MacroscopeDocument msDocAnalyzed in DocList.Keys) { DebugMsg(string.Format("msDocAnalyzed: {0} => {1}", DocList[msDocAnalyzed], msDocAnalyzed.GetUrl())); Assert.AreEqual(DocList[msDocAnalyzed], 0, string.Format("FAIL: {0} => {1}", DocList[msDocAnalyzed], msDocAnalyzed.GetUrl())); } } }
public void TestGenerateXmlSitemap() { foreach (string Url in this.Urls) { MacroscopeJobMaster JobMaster = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE); MacroscopeDocumentCollection DocCollection = new MacroscopeDocumentCollection(JobMaster: JobMaster); MacroscopeSitemapGenerator SitemapGenerator = new MacroscopeSitemapGenerator(NewDocCollection: DocCollection); DocCollection.AddDocument(new MacroscopeDocument(JobMaster.SetStartUrl(Url: Url))); XmlDocument SitemapXML = SitemapGenerator.GenerateXmlSitemap(Host: new Uri(Url).Host); Assert.AreEqual("urlset", SitemapXML.DocumentElement.LocalName); } }
public void TestWriteSitemapXml() { foreach (string Url in this.Urls) { MacroscopeJobMaster JobMaster = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE); MacroscopeDocumentCollection DocCollection = new MacroscopeDocumentCollection(JobMaster: JobMaster); MacroscopeSitemapGenerator SitemapGenerator = new MacroscopeSitemapGenerator(NewDocCollection: DocCollection); DocCollection.AddDocument(new MacroscopeDocument(JobMaster.SetStartUrl(Url: Url))); string Filename = string.Join(".", Path.GetTempFileName(), ".xml"); SitemapGenerator.WriteSitemapXml(NewPath: Filename); Assert.IsTrue(File.Exists(Filename)); if (File.Exists(Filename)) { File.Delete(Filename); } } }