public void ShouldSaveTagsIntoDatabase() { string startingUrl = @"http://www.samplesite.com/pages"; string link = @"pages/page1.htm"; IStorageProvider storageProvider = new MockStorageProvider(); IOutputProvider outputProvider = new MockOutputProvider(); int recursionLevel = 1; Uri uri = new Uri(startingUrl); string completeLink = uri.Scheme + @":\\" + new Uri(startingUrl).Authority + @"/" + link; if (!storageProvider.Contains(completeLink)) { outputProvider.WriteLine(completeLink + " " + (recursionLevel + 1).ToString()); storageProvider.TryAdd(completeLink, recursionLevel + 1); } Assert.IsTrue(storageProvider.GetRecords().Count == 1); Assert.IsTrue(storageProvider.GetRecords().ContainsKey(completeLink)); if (!storageProvider.Contains(completeLink)) { storageProvider.TryAdd(completeLink, recursionLevel + 1); } Assert.IsTrue(storageProvider.GetRecords().Count == 1); }
public void ShouldCallParsingForEachPageFromPreviousIteration() { IInputProvider inputProvider = new MockInputProvider(); IOutputProvider outputProvider = new MockOutputProvider(); IStorageProvider storageProvider = new MockStorageProvider(); IClientProvider clientProvider = new MockClientProvider(); IPageProvider pageProvider = new MockPageProvider(); ILinkProcessorProvider linkProcessorProvider = new MockLinkProcessorProvider(outputProvider, storageProvider); IPageParserProvider pageParserProvider = new MockPageParcerProvider(); WebPageProcessor wpp = new WebPageProcessor(storageProvider, inputProvider, outputProvider, pageProvider, linkProcessorProvider, pageParserProvider, 0); wpp.ProcessWebPage("Test", 0); Assert.IsTrue(storageProvider.Contains("Test1processed")); Assert.IsTrue(storageProvider.Contains("Test2processed")); Assert.IsTrue(storageProvider.Contains("Test3processed")); Assert.IsTrue(storageProvider.Contains("Test4processed")); Assert.IsTrue(storageProvider.Contains("Test5processed")); Assert.IsTrue(storageProvider.Contains("Test6processed")); Assert.IsTrue(storageProvider.Contains("Test7processed")); Assert.IsTrue(storageProvider.Contains("Test8processed")); }