Added MangaDex cover art logic. Added "Search Manga" test for MangaDex client.
This commit is contained in:
@@ -11,7 +11,7 @@ public class MangaDexMetadataTests
|
||||
[Fact]
|
||||
public async Task Get_Manga()
|
||||
{
|
||||
MangaDexEntityResponse entityResponse = new()
|
||||
MangaDexEntityResponse mangaEntityResponse = new()
|
||||
{
|
||||
Result = "ok",
|
||||
Response = "entity",
|
||||
@@ -141,7 +141,7 @@ public class MangaDexMetadataTests
|
||||
}
|
||||
};
|
||||
|
||||
MangaDexCollectionResponse collectionResponse = new()
|
||||
MangaDexCollectionResponse feedCollectionResponse = new()
|
||||
{
|
||||
Result = "ok",
|
||||
Response = "collection",
|
||||
@@ -186,13 +186,43 @@ public class MangaDexMetadataTests
|
||||
]
|
||||
};
|
||||
|
||||
MangaDexCollectionResponse coverArtCollectionResponse = new()
|
||||
{
|
||||
Result = "ok",
|
||||
Response = "collection",
|
||||
Data =
|
||||
[
|
||||
new CoverArtEntity()
|
||||
{
|
||||
Id = new Guid("0045f243-5625-4f0f-9066-a6c3a95d84d3"),
|
||||
Type = "cover_art",
|
||||
Attributes = new()
|
||||
{
|
||||
FileName = "2569ffd8-4ba1-4030-8d08-b7a21333a7a6.jpg"
|
||||
}
|
||||
},
|
||||
new CoverArtEntity()
|
||||
{
|
||||
Id = new Guid("a81ad8d3-ba2c-4003-9126-fbd9d28e3732"),
|
||||
Type = "cover_art",
|
||||
Attributes = new()
|
||||
{
|
||||
FileName = "d2314e9b-4287-4e65-8045-b713d97c0b28.jpg"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
IMangaDexClient mangaDexClient = Substitute.For<IMangaDexClient>();
|
||||
|
||||
mangaDexClient.GetMangaAsync(Arg.Any<Guid>(), CancellationToken.None)
|
||||
.Returns(entityResponse);
|
||||
.Returns(mangaEntityResponse);
|
||||
|
||||
mangaDexClient.GetFeedAsync(Arg.Any<Guid>(), CancellationToken.None)
|
||||
.Returns(collectionResponse);
|
||||
.Returns(feedCollectionResponse);
|
||||
|
||||
mangaDexClient.GetCoverArtAsync(Arg.Any<Guid>(), CancellationToken.None)
|
||||
.Returns(coverArtCollectionResponse);
|
||||
|
||||
MangaDexMetadataProvider metadataProvider = new(mangaDexClient);
|
||||
SourceManga? sourceManga = await metadataProvider.GetMangaAsync("https://mangadex.org/title/ee96e2b7-9af2-4864-9656-649f4d3b6fec/gals-can-t-be-kind-to-otaku", CancellationToken.None);
|
||||
@@ -248,5 +278,9 @@ public class MangaDexMetadataTests
|
||||
sourceManga.Chapters[2].Number.ShouldBe(8.1f);
|
||||
sourceManga.Chapters[2].Title.ShouldBe("Otaku & Gyaru & Protegee");
|
||||
sourceManga.Chapters[2].Url.ShouldBe("https://mangadex.org/chapter/b5206e9b-6e3e-4ef0-aa62-381fd0ff75a5");
|
||||
|
||||
sourceManga.CoverArt.Length.ShouldBe(2);
|
||||
sourceManga.CoverArt[0].ShouldBe("https://mangadex.org/covers/ee96e2b7-9af2-4864-9656-649f4d3b6fec/2569ffd8-4ba1-4030-8d08-b7a21333a7a6.jpg");
|
||||
sourceManga.CoverArt[1].ShouldBe("https://mangadex.org/covers/ee96e2b7-9af2-4864-9656-649f4d3b6fec/d2314e9b-4287-4e65-8045-b713d97c0b28.jpg");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user