diff --git a/Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs b/Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs
index 1615bb6..7ca480c 100644
--- a/Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs
+++ b/Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs
@@ -19,7 +19,7 @@ public partial class ScrapingAozoraService(ISplitBraceService splitBraceService,
private readonly ISplitBraceService _splitBraceService = splitBraceService;
private readonly IScrapingClientService _scrapingClientService = scrapingClientService;
- private EpubDocument _document;
+ private EpubDocument? _document;
public bool IsMatchSite(Uri uri)
diff --git a/KoeBook.Test/Epub/ScrapingAozoraServiceTest.cs b/KoeBook.Test/Epub/ScrapingAozoraServiceTest.cs
index 6b5a537..0f96c53 100644
--- a/KoeBook.Test/Epub/ScrapingAozoraServiceTest.cs
+++ b/KoeBook.Test/Epub/ScrapingAozoraServiceTest.cs
@@ -3,9 +3,6 @@
using AngleSharp.Dom;
using KoeBook.Epub.Models;
using KoeBook.Epub.Services;
-using System.Runtime.CompilerServices;
-using System.Linq;
-using System.Net.Http;
namespace KoeBook.Test.Epub;
@@ -18,9 +15,9 @@ public static object[][] ProcessChildrenTestCases()
(string, EpubDocument, EpubDocument)[] cases = [
// レイアウト
// 1.1 改丁
- (ToMainText(@"[#改丁]"), EmptySingleParagraph , new EpubDocument("", "", "", Guid.NewGuid()) { Chapters = [new Chapter() { Sections = [new Section("") { Elements = [new Paragraph() { Text = "[#改丁]", ScriptLine = new Core.Models.ScriptLine("", "", "") }] }] }] }),
+ (@"[#改丁]", EmptySingleParagraph , new EpubDocument("", "", "", Guid.NewGuid()) { Chapters = [new Chapter() { Sections = [new Section("") { Elements = [new Paragraph() { Text = "[#改丁]", ScriptLine = new Core.Models.ScriptLine("", "", "") }] }] }] }),
];
- return cases.Select(c => new object[] { c.Item1, c.Item2, c.Item3 }).ToArray();
+ return cases.Select(c => new object[] { ToMainText(c.Item1), c.Item2, c.Item3 }).ToArray();
}
///
@@ -44,7 +41,7 @@ public async void ProcessChildrenTest(string html, EpubDocument initial, EpubDoc
var scraper = new ScrapingAozoraService(new SplitBraceService(), new ScrapingClientService(new httpClientFactory(), TimeProvider.System));
scraper._document() = initial;
- scraper.ProcessChildren(mainText);
+ scraper.ProcessChildren(mainText!);
Assert.True(HaveSmaeText(scraper._document(), expexted));
}
@@ -62,16 +59,34 @@ private static bool HaveSmaeText(EpubDocument document, EpubDocument comparison)
same = (document.Title == comparison.Title);
same = (document.Author == comparison.Author);
same = (document.CssClasses == comparison.CssClasses);
+ same = (document.Chapters.Count == comparison.Chapters.Count);
foreach ((Chapter selfChapter, Chapter comparisonChapter) in document.Chapters.Zip(comparison.Chapters))
{
same = (selfChapter.Title == comparisonChapter.Title);
+ same = (selfChapter.Sections.Count == comparisonChapter.Sections.Count);
foreach ((Section selfSection, Section comparisonSection) in selfChapter.Sections.Zip(comparisonChapter.Sections))
{
same = (selfSection.Title == comparisonSection.Title);
-
- same = selfSection.Elements.Equals(comparisonSection.Elements);
+ same = (selfSection.Elements.Count == comparisonSection.Elements.Count);
+
+ foreach ((KoeBook.Epub.Models.Element selfElement, KoeBook.Epub.Models.Element comparisonElement) in selfSection.Elements.Zip(comparisonSection.Elements))
+ {
+ switch (selfElement, comparisonElement)
+ {
+ case (Paragraph selfParagraph, Paragraph comparisonParagraph):
+ same = (selfParagraph.Text == comparisonParagraph.Text);
+ same = (selfParagraph.ScriptLine?.Text == comparisonParagraph.ScriptLine?.Text);
+ break;
+ case (Picture selfPicture, Picture comparisonPicture):
+ same = (selfPicture.PictureFilePath == comparisonPicture.PictureFilePath);
+ break;
+ default:
+ same = false;
+ break;
+ }
+ }
}
}