Added contributor classes for manga. Implemented MangaDex search.

This commit is contained in:
2025-05-24 15:56:44 -04:00
parent f760cff21f
commit 1a752bb57e
20 changed files with 706 additions and 24 deletions

View File

@@ -0,0 +1,51 @@
using MangaReader.Core.HttpService;
using MangaReader.Core.Search;
using MangaReader.Core.Search.NatoManga;
using MangaReader.Tests.Utilities;
using NSubstitute;
using Shouldly;
namespace MangaReader.Tests.Search.NatoManga;
public class NatoMangaWebSearchTests
{
[Fact]
public void Get_Search_Url()
{
// Arrange
IHttpService httpService = Substitute.For<IHttpService>();
NatoMangaSearchProviderTestWrapper searchProvider = new(httpService);
// Act
string url = searchProvider.Test_GetSearchUrl("Gal can't be kind");
// Assert
url.ShouldBe("https://www.natomanga.com/home/search/json?searchword=gal_can_t_be_kind");
}
[Fact]
public async Task Get_Search_Result()
{
string resourceName = "MangaReader.Tests.Search.NatoManga.SampleSearchResult.json";
string searchResultJson = await ResourceHelper.ReadJsonResourceAsync(resourceName);
IHttpService httpService = Substitute.For<IHttpService>();
httpService.GetStringAsync(Arg.Any<string>())
.Returns(Task.FromResult(searchResultJson));
NatoMangaSearchProvider searchProvider = new(httpService);
MangaSearchResult[] searchResult = await searchProvider.SearchAsync("Gal Can't Be Kind");
searchResult.Length.ShouldBe(2);
searchResult[0].Title.ShouldBe("Gal Can't Be Kind to Otaku!");
searchResult[1].Title.ShouldBe("Gal Cant Be Kind to Otaku!?");
searchResult[0].Url.ShouldBe("https://www.natomanga.com/manga/gal-can-t-be-kind-to-otaku");
searchResult[1].Url.ShouldBe("https://www.natomanga.com/manga/gal-cant-be-kind-to-otaku");
}
}
internal class NatoMangaSearchProviderTestWrapper(IHttpService httpService) : NatoMangaSearchProvider(httpService)
{
internal string Test_GetSearchUrl(string keyword) => GetSearchUrl(keyword);
}