예제 #1
0
        public void HunkRange_ValidHunk_ExpectHunkNewFile()
        {
            //Arrange
            //Act
            var hunkRange = new HunkRange(@"42,20");

            //Assert
            hunkRange.StartingLineNumber.ShouldBe(41);
            hunkRange.NumberOfLines.ShouldBe(20);
        }
예제 #2
0
        public void HunkRange_HunkOriginalFile_ExpectHunkOriginalFile()
        {
            //Arrange
            //Act
            var hunkRange = new HunkRange(@"41,0");

            //Assert
            hunkRange.StartingLineNumber.ShouldBe(40);
            hunkRange.NumberOfLines.ShouldBe(0);
        }
예제 #3
0
        public void StartingLineNumber_HunkWithoutLineNumber_ExpectLineNumber()
        {
            //Arrange
            var hunkRange = new HunkRange(@"18");

            //Act
            var startingLineNumber = hunkRange.StartingLineNumber;

            //Assert
            startingLineNumber.ShouldBe(17);
        }
예제 #4
0
        public void NumberOfLines_HunkWithoutLineNumber_ExpectDefaultTo1LineNumber()
        {
            //Arrange
            var hunkRange = new HunkRange(@"-18");

            //Act
            var numberOfLines = hunkRange.NumberOfLines;

            //Assert
            numberOfLines.ShouldBe(1);
        }
예제 #5
0
        public HunkRangeInfo(HunkRange originaleHunkRange, HunkRange newHunkRange, IEnumerable <string> diffLines)
        {
            OriginalHunkRange = originaleHunkRange;
            NewHunkRange      = newHunkRange;
            DiffLines         = diffLines.ToList();

            IsAddition     = DiffLines.All(s => s.StartsWith("+") || string.IsNullOrWhiteSpace(s));
            IsDeletion     = DiffLines.All(s => s.StartsWith("-") || string.IsNullOrWhiteSpace(s));
            IsModification = !IsAddition && !IsDeletion;

            if (IsDeletion || IsModification)
            {
                OriginalText = DiffLines.Where(s => s.StartsWith("-")).Select(s => s.Remove(0, 1).TrimEnd('\n').TrimEnd('\r')).ToList();
            }
        }
예제 #6
0
        public HunkRangeInfo(HunkRange originaleHunkRange, HunkRange newHunkRange, IEnumerable<string> diffLines)
        {
            OriginalHunkRange = originaleHunkRange;
            NewHunkRange = newHunkRange;
            DiffLines = diffLines.ToList();

            IsAddition = DiffLines.All(s => s.StartsWith("+") || string.IsNullOrWhiteSpace(s));
            IsDeletion = DiffLines.All(s => s.StartsWith("-") || string.IsNullOrWhiteSpace(s));
            IsModification = !IsAddition && !IsDeletion;

            if (IsDeletion || IsModification)
            {
                OriginalText = DiffLines.Where(s => s.StartsWith("-")).Select(s => s.Remove(0, 1).TrimEnd('\n').TrimEnd('\r')).ToList();
            }
        }
예제 #7
0
 public HunkRangeInfo(HunkRange originaleHunkRange, HunkRange newHunkRange, IEnumerable<string> diffLines)
     : this(originaleHunkRange, newHunkRange, diffLines, false)
 {
 }
예제 #8
0
 public HunkRangeInfo(HunkRange originaleHunkRange, HunkRange newHunkRange, IEnumerable <string> diffLines)
     : this(originaleHunkRange, newHunkRange, diffLines, false)
 {
 }