public void HunkRange_ValidHunk_ExpectHunkNewFile() { //Arrange //Act var hunkRange = new HunkRange(@"42,20"); //Assert hunkRange.StartingLineNumber.ShouldBe(41); hunkRange.NumberOfLines.ShouldBe(20); }
public void HunkRange_HunkOriginalFile_ExpectHunkOriginalFile() { //Arrange //Act var hunkRange = new HunkRange(@"41,0"); //Assert hunkRange.StartingLineNumber.ShouldBe(40); hunkRange.NumberOfLines.ShouldBe(0); }
public void StartingLineNumber_HunkWithoutLineNumber_ExpectLineNumber() { //Arrange var hunkRange = new HunkRange(@"18"); //Act var startingLineNumber = hunkRange.StartingLineNumber; //Assert startingLineNumber.ShouldBe(17); }
public void NumberOfLines_HunkWithoutLineNumber_ExpectDefaultTo1LineNumber() { //Arrange var hunkRange = new HunkRange(@"-18"); //Act var numberOfLines = hunkRange.NumberOfLines; //Assert numberOfLines.ShouldBe(1); }
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(); } }
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(); } }
public HunkRangeInfo(HunkRange originaleHunkRange, HunkRange newHunkRange, IEnumerable<string> diffLines) : this(originaleHunkRange, newHunkRange, diffLines, false) { }
public HunkRangeInfo(HunkRange originaleHunkRange, HunkRange newHunkRange, IEnumerable <string> diffLines) : this(originaleHunkRange, newHunkRange, diffLines, false) { }