Files
manga-reader/MangaReader.Tests/WebCrawlers/NatoManga/NatoMangaWebCrawlerTests.cs

66 lines
2.7 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 async Task Get_Manga()
{
string sampleFilePath = Path.Combine(AppContext.BaseDirectory, "WebCrawlers", "NatoManga", "SampleMangaPage.html");
var webCrawler = new TestNatoMangaWebCrawler();
var manga = await webCrawler.GetMangaAsync(sampleFilePath, CancellationToken.None);
manga.ShouldNotBeNull();
manga.Title.ShouldBe("Gal Cant Be Kind to Otaku!?");
//manga.AlternateTitles.ShouldBe([
// "Kaette kudasai! Akutsu-san",
// "Yankee Musume",
// "ヤンキー娘",
// "帰ってください! 阿久津さん"]);
//manga.Authors.ShouldBe(["Nagaoka Taichi"]);
//manga.Status.ShouldBe(MangaStatus.Ongoing);
manga.Genres.ShouldBe(["Comedy", "Harem", "Romance", "School life", "Seinen", "Slice of life"]);
//manga.UpdateDate.ShouldBe(new DateTime(2024, 9, 26, 0, 12, 0));
//manga.Views.ShouldBe(93_300_000);
//manga.RatingPercent.ShouldBe(97);
//manga.Votes.ShouldBe(15979);
////manga.Description.ShouldStartWith("Ooyama-kun normally doesnt get involved with Akutsu-san, a delinquent girl in his class");
//manga.Description.ShouldStartWith("Ooyama-kun normally doesnt get involved with Akutsu-san, a delinquent girl in his class");
//manga.Description.ShouldEndWith("Artist's Pixiv: https://www.pixiv.net/member.php?id=133935");
manga.Chapters.Count.ShouldBe(83);
manga.Chapters[0].Url.ShouldBe("https://www.natomanga.com/manga/gal-cant-be-kind-to-otaku/chapter-69");
manga.Chapters[0].Number.ShouldBe(69);
manga.Chapters[0].Name.ShouldBe("Chapter 69");
manga.Chapters[0].Views.ShouldBe(8146);
//manga.Chapters[0].UploadDate.ShouldBe(new DateTime(2025, 4, 23, 17, 17, 0));
//manga.Chapters[235].URL.ShouldBe("https://chapmanganato.to/manga-hf984788/chapter-0.1");
//manga.Chapters[235].Number.ShouldBe(0.1f);
//manga.Chapters[235].Name.ShouldBe("Vol.0 Chapter : Oneshot");
//manga.Chapters[235].Views.ShouldBe(232_200);
//manga.Chapters[235].UploadDate.ShouldBe(new DateTime(2021, 8, 24, 1, 8, 0));
}
}