public async Task MangaReader_Test() { string url = "https://www.mangareader.net/naruto"; var service = new MangaReader(logger, downloader, new HtmlAtilityPackAdapter()); Assert.IsTrue(service.Of(url)); // Test service can find chapters var chapters = await service.FindChapters(url, new Progress <int>(), source.Token); Assert.IsTrue(chapters.Any(), "Cannot find chapters."); // Test chapters are in correct order. var chapter = chapters.Last(); Assert.AreEqual("Naruto", chapter.Manga); Assert.AreEqual("Naruto 1", chapter.DisplayName); Assert.AreEqual("https://www.mangareader.net/naruto/1", chapter.Url); // Test there're no duplicated chapters. var anyDuplicated = chapters.GroupBy(x => x.Url).Any(g => g.Count() > 1); Assert.IsFalse(anyDuplicated, "There're duplicated chapters."); // Test service can find images. var images = await service.FindImages(chapter, new Progress <int>(), source.Token); Assert.AreEqual(53, images.Count()); Assert.AreEqual("https://i10.mangareader.net/naruto/1/naruto-1564773.jpg", images.ToArray()[0]); Assert.AreEqual("https://i4.mangareader.net/naruto/1/naruto-1564774.jpg", images.ToArray()[1]); Assert.AreEqual("https://i1.mangareader.net/naruto/1/naruto-1564825.jpg", images.ToArray()[52]); string imageString = await downloader.DownloadStringAsync(images.ToArray()[0], source.Token); Assert.IsNotNull(imageString, "Cannot download image!"); }
public async Task FindChapters() { string url = "https://www.mangareader.net/naruto"; Assert.True(service.Of(url)); // Test service can find chapters var chapters = await service.GetChapters(url, new Progress <string>(), source.Token); Assert.True(chapters.Any(), "Cannot find chapters."); // Test chapters are in correct order. var chapter = chapters.Last(); Assert.Equal("Naruto 1", chapter.Name); Assert.Equal("https://www.mangareader.net/naruto/1", chapter.Url); // Test there're no duplicated chapters. var anyDuplicated = chapters.GroupBy(x => x.Url).Any(g => g.Count() > 1); Assert.False(anyDuplicated, "There're duplicated chapters."); }