47 lines
1.9 KiB
C#
47 lines
1.9 KiB
C#
using MangaReader.Core.Search;
|
||
using MangaReader.Core.Sources.NatoManga.Api;
|
||
using MangaReader.Core.Sources.NatoManga.Search;
|
||
using NSubstitute;
|
||
using Shouldly;
|
||
|
||
namespace MangaReader.Tests.Sources.NatoManga.Search;
|
||
|
||
public class NatoMangaSearchTests
|
||
{
|
||
[Fact]
|
||
public async Task Get_Search_Result()
|
||
{
|
||
NatoMangaSearchResult[] searchResults =
|
||
[
|
||
new()
|
||
{
|
||
Name = "Gal Can't Be Kind to Otaku!",
|
||
Url = "https://www.natomanga.com/manga/gal-can-t-be-kind-to-otaku",
|
||
Thumb = "https://img-r1.2xstorage.com/thumb/gal-can-t-be-kind-to-otaku.webp"
|
||
},
|
||
new()
|
||
{
|
||
Name = "Gal Can’t Be Kind to Otaku!?",
|
||
Url = "https://www.natomanga.com/manga/gal-cant-be-kind-to-otaku",
|
||
Thumb = "https://img-r1.2xstorage.com/thumb/gal-cant-be-kind-to-otaku.webp"
|
||
}
|
||
];
|
||
|
||
INatoMangaClient natoMangaClient = Substitute.For<INatoMangaClient>();
|
||
|
||
natoMangaClient.SearchAsync(Arg.Any<string>(), CancellationToken.None)
|
||
.Returns(Task.FromResult(searchResults));
|
||
|
||
NatoMangaSearchProvider searchProvider = new(natoMangaClient);
|
||
MangaSearchResult[] searchResult = await searchProvider.SearchAsync("Gal Can't Be Kind", CancellationToken.None);
|
||
|
||
searchResult.Length.ShouldBe(2);
|
||
searchResult[0].Title.ShouldBe("Gal Can't Be Kind to Otaku!");
|
||
searchResult[0].Url.ShouldBe("https://www.natomanga.com/manga/gal-can-t-be-kind-to-otaku");
|
||
searchResult[0].Thumbnail.ShouldBe("https://img-r1.2xstorage.com/thumb/gal-can-t-be-kind-to-otaku.webp");
|
||
|
||
searchResult[1].Title.ShouldBe("Gal Can’t Be Kind to Otaku!?");
|
||
searchResult[1].Url.ShouldBe("https://www.natomanga.com/manga/gal-cant-be-kind-to-otaku");
|
||
searchResult[1].Thumbnail.ShouldBe("https://img-r1.2xstorage.com/thumb/gal-cant-be-kind-to-otaku.webp");
|
||
}
|
||
} |