", "[#改段]", "")]
+ public async void ProcessChildrenlayout1Test(string html, string expectedPragraphText, string expectedScriptText)
{
var config = Configuration.Default.WithDefaultLoader();
using var context = BrowsingContext.New(config);
var doc = await context.OpenAsync(request => request.Content(html));
- var mainText = doc.QuerySelector(".main_text");
+ var mainText = doc.DocumentElement.LastElementChild?.LastElementChild;
if (mainText == null)
Assert.Fail();
var document = EmptySingleParagraph;
_scrapingAozoraService.ProcessChildren(document, mainText, "");
- Assert.Single(document.Chapters);
- Assert.Single(document.Chapters[^1].Sections);
- Assert.Single(document.Chapters[^1].Sections);
- Assert.IsType
(document.Chapters[^1].Sections[^1].Elements[^1]);
- if (document.Chapters[^1].Sections[^1].Elements[^1] is Paragraph paragraph)
- {
- Assert.Equal(expected.Text, paragraph.Text);
- Assert.Equal(expected.ClassName, paragraph.ClassName);
- Assert.NotNull(paragraph.ScriptLine);
- Assert.Equal(expected.ScriptLine?.Text, paragraph.ScriptLine.Text);
- }
+ var chapter = Assert.Single(document.Chapters);
+ var section = Assert.Single(chapter.Sections);
+ var paragraph = Assert.IsType(section.Elements[^1]);
+ Assert.Equal(expectedPragraphText, paragraph.Text);
+ Assert.Equal(string.Empty, paragraph.ClassName);
+ Assert.NotNull(paragraph.ScriptLine);
+ Assert.Equal(expectedScriptText, paragraph.ScriptLine.Text);
}
// Classes の各 value は、対応するclass で、ソースに出てきたものの内、最大のものの値をほじするようにする。
@@ -121,16 +109,16 @@ public async void ProcessChildrenlayout2Test(string html, IReadOnlyCollection
- {
+ {
var actualParagraph = Assert.IsType(v.Second);
Assert.Equal(v.First.Text, actualParagraph.Text);
Assert.Equal(v.First.ClassName, actualParagraph.ClassName);
- Assert.NotNull(actualParagraph.ScriptLine);
+ Assert.NotNull(actualParagraph.ScriptLine);
Assert.Equal(v.First.ScriptLine?.Text, actualParagraph.ScriptLine.Text);
});
- // ScrapingAozoraService.Classes の確認
+ // ScrapingAozoraService.Classes の確認
Assert.All(expectedDictionary, expectedKeyValuePair =>
- {
+ {
Assert.True(_scrapingAozoraService._Classes().TryGetValue(expectedKeyValuePair.key, out var actualValue));
Assert.True(actualValue.min <= expectedKeyValuePair.value.min);
Assert.True(actualValue.max >= expectedKeyValuePair.value.max);