Updated web crawler logic.
This commit is contained in:
@@ -1,17 +1,31 @@
|
||||
using MangaReader.Core.Sources.NatoManga.Metadata;
|
||||
using HtmlAgilityPack;
|
||||
using MangaReader.Core.Sources.NatoManga.Metadata;
|
||||
using Shouldly;
|
||||
|
||||
namespace MangaReader.Tests.WebCrawlers.NatoManga;
|
||||
|
||||
public class NatoMangaWebCrawlerTests
|
||||
{
|
||||
class TestNatoMangaWebCrawler : NatoMangaWebCrawler
|
||||
{
|
||||
protected override Task<HtmlDocument> GetHtmlDocumentAsync(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
HtmlWeb web = new()
|
||||
{
|
||||
UsingCacheIfExists = false
|
||||
};
|
||||
|
||||
return Task.FromResult(web.Load(url));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_Manga()
|
||||
public async Task Get_Manga()
|
||||
{
|
||||
string sampleFilePath = Path.Combine(AppContext.BaseDirectory, "WebCrawlers", "NatoManga", "SampleMangaPage.html");
|
||||
|
||||
var webCrawler = new NatoMangaWebCrawler();
|
||||
var manga = webCrawler.GetManga(sampleFilePath);
|
||||
var webCrawler = new TestNatoMangaWebCrawler();
|
||||
var manga = await webCrawler.GetMangaAsync(sampleFilePath, CancellationToken.None);
|
||||
|
||||
manga.ShouldNotBeNull();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MangaReader.Core.Metadata;
|
||||
using HtmlAgilityPack;
|
||||
using MangaReader.Core.Metadata;
|
||||
using MangaReader.Core.Sources.MangaNato.Metadata;
|
||||
using Shouldly;
|
||||
|
||||
@@ -6,6 +7,19 @@ namespace MangaReader.Tests.WebCrawlers;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
class TestMangaNatoWebCrawler : MangaNatoWebCrawler
|
||||
{
|
||||
protected override Task<HtmlDocument> GetHtmlDocumentAsync(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
HtmlWeb web = new()
|
||||
{
|
||||
UsingCacheIfExists = false
|
||||
};
|
||||
|
||||
return Task.FromResult(web.Load(url));
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string samplesPath;
|
||||
private readonly string mangaNatoSampleFilePath;
|
||||
|
||||
@@ -16,10 +30,10 @@ public class UnitTest1
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_Manga()
|
||||
public async Task Get_Manga()
|
||||
{
|
||||
var webCrawler = new MangaNatoWebCrawler();
|
||||
var manga = webCrawler.GetManga(mangaNatoSampleFilePath);
|
||||
var webCrawler = new TestMangaNatoWebCrawler();
|
||||
var manga = await webCrawler.GetMangaAsync(mangaNatoSampleFilePath, CancellationToken.None);
|
||||
|
||||
manga.ShouldNotBeNull();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user