Files
manga-reader/MangaReader.Tests/Sources/MangaNato/Metadata/MangaNatoMetadataTests.cs
2025-06-25 10:40:03 -04:00

76 lines
3.0 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 MangaReader.Core.Common;
using MangaReader.Core.Http;
using MangaReader.Core.Metadata;
using MangaReader.Core.Sources.MangaNato.Metadata;
using MangaReader.Tests.Utilities;
using NSubstitute;
using Shouldly;
using System.Data;
namespace MangaReader.Tests.Sources.MangaNato.Metadata;
public class MangaNatoMetadataTests
{
[Fact]
public async Task Get_Manga()
{
string mangaHtml = await ReadJsonResourceAsync("Manga-Response.html");
IHttpService httpService = Substitute.For<IHttpService>();
httpService.GetStringAsync(Arg.Any<string>(), CancellationToken.None)
.Returns(Task.FromResult(mangaHtml));
HtmlLoader htmlLoader = new(httpService);
MangaNatoWebCrawler webCrawler = new(htmlLoader);
SourceManga? manga = await webCrawler.GetMangaAsync("/test-url", CancellationToken.None);
manga.ShouldNotBeNull();
manga.Title.Name.ShouldBe("Please Go Home, Akutsu-San!");
manga.AlternateTitles.Select(x => x.Name).ShouldBe([
"Kaette kudasai! Akutsu-san",
"Yankee Musume",
"ヤンキー娘",
"帰ってください! 阿久津さん"]);
SourceMangaContributor[] expectedContributors =
[
new() { Name = "Nagaoka Taichi", Role = ContributorRole.Author }
];
manga.Contributors.ShouldBeEquivalentTo(expectedContributors);
manga.Status.ShouldBe(MangaStatus.Ongoing);
manga.Genres.ShouldBe(["Comedy", "Romance", "School 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?.Name.ShouldStartWith("Ooyama-kun normally doesnt get involved with Akutsu-san, a delinquent girl in his class");
manga.Description?.Name.ShouldEndWith("Artist's Pixiv: https://www.pixiv.net/member.php?id=133935");
manga.Chapters.Count.ShouldBe(236);
manga.Chapters[0].Url.ShouldBe("https://chapmanganato.to/manga-hf984788/chapter-186");
manga.Chapters[0].Number.ShouldBe(186);
manga.Chapters[0].Title.ShouldBe("Chapter 186");
manga.Chapters[0].Views.ShouldBe(37_900);
manga.Chapters[0].UploadDate.ShouldBe(new DateTime(2024, 9, 26, 0, 9, 0));
manga.Chapters[235].Url.ShouldBe("https://chapmanganato.to/manga-hf984788/chapter-0.1");
manga.Chapters[235].Number.ShouldBe(0.1f);
manga.Chapters[235].Title.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));
}
private static async Task<string> ReadJsonResourceAsync(string resourceName)
{
return await ResourceHelper.ReadJsonResourceAsync($"MangaReader.Tests.Sources.MangaNato.Metadata.{resourceName}");
}
}