public void CanCheckIfTheLineStartsWithSpecificPrefix(string diffText, string prefix)
        {
            var lineSegmentGetter = PrepareliLineSegmentGetter(diffText);

            var doc = PreDocumentForDiffText(diffText);

            var helper = new LinePrefixHelper(lineSegmentGetter);
            helper.DoesLineStartWith(doc, 0, prefix).Should().BeTrue();
        }
        public void CanFindDeletedLines()
        {
            const string diffText = @"+added line 1
+added line 2
-removed line1
-removed line2";

            var lineSegmentGetter = PrepareliLineSegmentGetter(diffText);

            var doc = PreDocumentForDiffText(diffText);

            var beginIndex = 0;
            var found = false;

            var lines = new LinePrefixHelper(lineSegmentGetter)
                .GetLinesStartingWith(doc, ref beginIndex, "-", ref found);

            lines.Count.Should().Be(2);
            beginIndex.Should().Be(4);
            found.Should().BeTrue();
        }
示例#3
0
 protected override List <ISegment> GetRemovedLines(IDocument document, ref int line, ref bool found)
 {
     return(LinePrefixHelper.GetLinesStartingWith(document, ref line, new[] { "-", " -" }, ref found));
 }
        public void GivenThatTheDocDoesnotHaveEnoughChars_ShouldReturnFalseWhenCheckPrefix(string diffText)
        {
            var lineSegmentGetter = PrepareliLineSegmentGetter(diffText);

            var doc = PreDocumentForDiffText(diffText);

            var helper = new LinePrefixHelper(lineSegmentGetter);
            helper.DoesLineStartWith(doc, 0, "++").Should().BeFalse();
        }