public void ProvideChapterMarkersShouldProvideMarkersFromOptionsWhenPresent() { _options.ChapterMarkers.Returns(new List <string> { "ch1", "ch2" }); _provider.ProvideChapterMarkers(null).Should().BeEquivalentTo("ch1", "ch2"); }
public ContentsInfo Analyze(MarkingTextReader reader) { var chapterMarkers = _markersProvider.ProvideChapterMarkers(reader.Lines).ToArray(); var contents = new ContentsInfo { ChapterFiles = new List <ContentsMapping>(chapterMarkers.Length + 1) }; int startLine = 0; int chapterIndex = 0; for (chapterIndex = 0; chapterIndex < chapterMarkers.Length; chapterIndex++) { var count = reader.CountLinesUntilMarker(chapterMarkers[chapterIndex], chapterIndex == 0); contents.ChapterFiles.Add(new ContentsMapping() { Name = $"ch{chapterIndex}", StartLine = startLine, LengthInLines = count, PlainTextContent = new List <string>(count), }); Copy(reader.Lines, contents.ChapterFiles[chapterIndex]); startLine += count; } contents.ChapterFiles.Add(new ContentsMapping() { Name = $"ch{chapterIndex}", StartLine = startLine, LengthInLines = reader.CountLinesUntilEnd() + (startLine > 0 ? 1 : 0), PlainTextContent = new List <string>(), }); Copy(reader.Lines, contents.ChapterFiles[chapterIndex]); return(contents); }