Exemplo n.º 1
0
        public void Setup()
        {
            _options = Substitute.For <IOptionProviderChapterMarkers>();
            _options.ChapterMarkers.Returns(new string[] { "第1章", "第2章", "第3章" });


            _breaker = new ContentsBreaker(new ChapterMarkersProvider(_options, null));
            using (var reader = new MarkingTextReader(new StringReader(_text)))
            {
                _contents = _breaker.Analyze(reader);
            }
        }
Exemplo n.º 2
0
        public void AnalyzeShouldDetectSingleChapter0WhenChapterMarkersAreEmpty()
        {
            var noMarkers = Substitute.For <IChapterMarkersProvider>();

            noMarkers.ProvideChapterMarkers(null).Returns(new string[] { });

            ContentsInfo zeroContents;
            var          zeroBreaker = new ContentsBreaker(noMarkers);

            using (var reader = new MarkingTextReader(new StringReader(_text)))
            {
                zeroContents = zeroBreaker.Analyze(reader);
            }

            Assert.AreEqual(1, zeroContents.ChapterFiles.Count, "ChapterFiles Count");
            Assert.AreEqual("ch0", zeroContents.ChapterFiles[0].Name, "FilePath");
            Assert.AreEqual(0, zeroContents.ChapterFiles[0].StartLine, "StartLine");
            Assert.AreEqual(13, zeroContents.ChapterFiles[0].LengthInLines, "LengthInLines");

            zeroContents.ChapterFiles[0].PlainTextContent.Should().BeEquivalentTo(_text.Split('\n'));
        }