Project restructuring.
This commit is contained in:
108
MangaReader.Tests/Sources/MangaDex/Search/MangaDexSearchTests.cs
Normal file
108
MangaReader.Tests/Sources/MangaDex/Search/MangaDexSearchTests.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using MangaReader.Core.Search;
|
||||
using MangaReader.Core.Sources.MangaDex.Api;
|
||||
using MangaReader.Core.Sources.MangaDex.Search;
|
||||
using NSubstitute;
|
||||
using Shouldly;
|
||||
|
||||
namespace MangaReader.Tests.Sources.MangaDex.Search;
|
||||
|
||||
public class MangaDexSearchTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Get_Search_Result()
|
||||
{
|
||||
MangaDexCollectionResponse collectionResponse = new()
|
||||
{
|
||||
Result = "ok",
|
||||
Response = "collection",
|
||||
Data =
|
||||
[
|
||||
new MangaEntity()
|
||||
{
|
||||
Id = new Guid("ee96e2b7-9af2-4864-9656-649f4d3b6fec"),
|
||||
Type = "manga",
|
||||
Attributes = new()
|
||||
{
|
||||
Title = new()
|
||||
{
|
||||
{ "en", "Gals Can’t Be Kind to Otaku!?" }
|
||||
}
|
||||
},
|
||||
Relationships =
|
||||
[
|
||||
new CoverArtEntity()
|
||||
{
|
||||
Id = new Guid("a06943fd-6309-49a8-a66a-8df0f6dc41eb"),
|
||||
Type = "cover_art",
|
||||
Attributes = new()
|
||||
{
|
||||
FileName = "6b3073de-bb65-4723-8113-6068bf8c6eb4.jpg"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
new MangaEntity()
|
||||
{
|
||||
Id = new Guid("16c34950-954c-4f0d-808e-d8278a546339"),
|
||||
Type = "manga",
|
||||
Attributes = new()
|
||||
{
|
||||
Title = new()
|
||||
{
|
||||
{ "en", "Suufungo no Mirai ga Wakaru You ni Natta Kedo, Onnagokoro wa Wakaranai." }
|
||||
}
|
||||
},
|
||||
Relationships =
|
||||
[
|
||||
new CoverArtEntity()
|
||||
{
|
||||
Id = new Guid("ee8588b5-145f-4eee-981a-eb604856fbd2"),
|
||||
Type = "cover_art",
|
||||
Attributes = new()
|
||||
{
|
||||
FileName = "7d301e1e-642b-4b7d-b65b-9777b36e80bf.jpg"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
new MangaEntity()
|
||||
{
|
||||
Id = new Guid("f395bfc6-e52f-4f64-9cfb-87037215d214"),
|
||||
Type = "manga",
|
||||
Attributes = new()
|
||||
{
|
||||
Title = new()
|
||||
{
|
||||
{ "en", "Ienai Himitsu No Aishikata" }
|
||||
}
|
||||
},
|
||||
Relationships =
|
||||
[
|
||||
new CoverArtEntity()
|
||||
{
|
||||
Id = new Guid("40df2d2e-b786-4aa9-9218-e3ed168cd96e"),
|
||||
Type = "cover_art",
|
||||
Attributes = new()
|
||||
{
|
||||
FileName = "c00a33cd-b26b-4554-a9f0-d6885c81eb36.jpg"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
IMangaDexClient mangaDexClient = Substitute.For<IMangaDexClient>();
|
||||
|
||||
mangaDexClient.SearchMangaByTitleAsync(Arg.Any<string>(), CancellationToken.None)
|
||||
.Returns(collectionResponse);
|
||||
|
||||
MangaDexSearchProvider searchProvider = new(mangaDexClient);
|
||||
MangaSearchResult[] searchResult = await searchProvider.SearchAsync("Gal Can't Be Kind", CancellationToken.None);
|
||||
|
||||
searchResult.Length.ShouldBe(3);
|
||||
searchResult[0].Title.ShouldBe("Gals Can’t Be Kind to Otaku!?");
|
||||
searchResult[0].Url.ShouldBe("https://mangadex.org/title/ee96e2b7-9af2-4864-9656-649f4d3b6fec/gals-can-t-be-kind-to-otaku");
|
||||
searchResult[0].Thumbnail.ShouldBe("https://mangadex.org/covers/ee96e2b7-9af2-4864-9656-649f4d3b6fec/6b3073de-bb65-4723-8113-6068bf8c6eb4.jpg");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user