public void TestDeleteLineWithConflicts() { TextFileInformation tfi = new TextFileInformation(); tfi.NewGenFile = new TextFile("line 0\r\nline 12\r\nline 2"); tfi.UserFile = new TextFile("line 0\r\nline 13\r\nline 2"); tfi.PrevGenFile = new TextFile("line 0\r\nline 1\r\nline 2"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.RightLines, Has.Count(4)); Assert.That(output.LeftLines, Has.Count(4)); output.RemoveLine(0); Assert.That(output.RightLines, Has.Count(3)); Assert.That(output.LeftLines, Has.Count(3)); Assert.That(output.LeftLines[0].Text, Is.EqualTo("line 13")); Assert.That(output.RightLines[0].Text, Is.EqualTo("")); Assert.That(output.RightLines[0].IsVirtual, Is.EqualTo(true)); Assert.That(output.ConflictRanges[0].StartLineIndex, Is.EqualTo(0)); Assert.That(output.ConflictRanges[0].EndLineIndex, Is.EqualTo(2)); }
public void TestTemplateChange_Delete_At_End() { TextFileInformation tfi = new TextFileInformation(); tfi.PrevGenFile = tfi.UserFile = new TextFile("line1\nline2"); tfi.NewGenFile = new TextFile("line1"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.RightLines, Is.Not.Empty); Assert.That(output.LeftLines, Is.Not.Empty); Assert.That(output.LeftLines, Has.Count(2)); Assert.That(output.RightLines, Has.Count(2)); Assert.That(output.LeftLines[0].Text, Is.EqualTo("line1")); Assert.That(output.LeftLines[1].Text, Is.EqualTo("line2")); Assert.That(output.RightLines[0].Text, Is.EqualTo("line1")); Assert.That(output.RightLines[1].Text, Is.EqualTo("")); Assert.That(output.LeftLines[0].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.LeftLines[1].Change, Is.EqualTo(ChangeType.Template)); Assert.That(output.RightLines[0].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.RightLines[1].Change, Is.EqualTo(ChangeType.Template)); Assert.That(output.RightLines[1].IsVirtual, Is.True); }
public void TestConflictOperations_NoConflicts() { TextFileInformation tfi = new TextFileInformation(); tfi.NewGenFile = new TextFile("line 0\r\nline 1\r\nline 2"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.IsLineInConflict(0), Is.False); Assert.That(output.GetConflictBefore(0), Is.Null); Assert.That(output.GetConflictAfter(0), Is.Null); }
public void TestConflict_At_Start_Add_At_End() { TextFileInformation tfi = new TextFileInformation(); tfi.PrevGenFile = new TextFile( "line1\nline3"); tfi.UserFile = new TextFile("line00\nline1\nline2\nline3"); tfi.NewGenFile = new TextFile("line0\nline1\nline3\nline4"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.RightLines, Is.Not.Empty); Assert.That(output.LeftLines, Is.Not.Empty); Assert.That(output.LeftLines, Has.Count(6)); Assert.That(output.RightLines, Has.Count(6)); Assert.That(output.LeftLines[0].Text, Is.EqualTo("line00"), "Line 1 on left"); Assert.That(output.LeftLines[1].Text, Is.EqualTo("line0"), "Line 2 on left"); Assert.That(output.LeftLines[2].Text, Is.EqualTo("line1"), "Line 3 on left"); Assert.That(output.LeftLines[3].Text, Is.EqualTo(""), "Line 4 on left"); Assert.That(output.LeftLines[4].Text, Is.EqualTo("line3"), "Line 5 on left"); Assert.That(output.LeftLines[5].Text, Is.EqualTo(""), "Line 5 on left"); Assert.That(output.RightLines[0].Text, Is.EqualTo(""), "Line 1 on right"); Assert.That(output.RightLines[1].Text, Is.EqualTo(""), "Line 2 on right"); Assert.That(output.RightLines[2].Text, Is.EqualTo("line1"), "Line 3 on right"); Assert.That(output.RightLines[3].Text, Is.EqualTo("line2"), "Line 4 on right"); Assert.That(output.RightLines[4].Text, Is.EqualTo("line3"), "Line 5 on right"); Assert.That(output.RightLines[5].Text, Is.EqualTo("line4"), "Line 6 on right"); Assert.That(output.LeftLines[0].Change, Is.EqualTo(ChangeType.User)); Assert.That(output.LeftLines[1].Change, Is.EqualTo(ChangeType.Template)); Assert.That(output.LeftLines[2].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.LeftLines[3].IsVirtual, Is.True); Assert.That(output.LeftLines[4].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.LeftLines[5].IsVirtual, Is.True); Assert.That(output.RightLines[0].IsVirtual, Is.True); Assert.That(output.RightLines[1].IsVirtual, Is.True); Assert.That(output.RightLines[2].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.RightLines[3].Change, Is.EqualTo(ChangeType.User)); Assert.That(output.RightLines[4].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.RightLines[5].Change, Is.EqualTo(ChangeType.Template)); }
public void UserAndTemplate_Two_Changes_In_Middle() { TextFileInformation tfi = new TextFileInformation(); tfi.PrevGenFile = new TextFile("line0\nline1\nline2\nline3"); tfi.UserFile = new TextFile("line0\nline11\nline12\nline2\nline3"); tfi.NewGenFile = new TextFile("line0\nline1\nline21\nline3"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.That(output.DiffType, Is.EqualTo(Slyce.IntelliMerge.TypeOfDiff.UserAndTemplateChange)); Assert.IsNotNull(output); Assert.That(output.RightLines, Is.Not.Empty); Assert.That(output.LeftLines, Is.Not.Empty); Assert.That(output.LeftLines, Has.Count(5)); Assert.That(output.RightLines, Has.Count(5)); Assert.That(output.LeftLines[0].Text, Is.EqualTo("line0")); Assert.That(output.LeftLines[1].Text, Is.EqualTo("line1")); Assert.That(output.LeftLines[2].Text, Is.EqualTo("")); Assert.That(output.LeftLines[3].Text, Is.EqualTo("line2")); Assert.That(output.LeftLines[4].Text, Is.EqualTo("line3")); Assert.That(output.RightLines[0].Text, Is.EqualTo("line0")); Assert.That(output.RightLines[1].Text, Is.EqualTo("line11")); Assert.That(output.RightLines[2].Text, Is.EqualTo("line12")); Assert.That(output.RightLines[3].Text, Is.EqualTo("line21")); Assert.That(output.RightLines[4].Text, Is.EqualTo("line3")); Assert.That(output.LeftLines[0].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.LeftLines[1].Change, Is.EqualTo(ChangeType.User)); Assert.That(output.LeftLines[2].Change, Is.EqualTo(ChangeType.User)); Assert.That(output.LeftLines[2].IsVirtual, Is.EqualTo(true)); Assert.That(output.LeftLines[3].Change, Is.EqualTo(ChangeType.Template)); Assert.That(output.LeftLines[4].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.RightLines[0].Change, Is.EqualTo(ChangeType.None)); Assert.That(output.RightLines[1].Change, Is.EqualTo(ChangeType.User)); Assert.That(output.RightLines[2].Change, Is.EqualTo(ChangeType.User)); Assert.That(output.RightLines[3].Change, Is.EqualTo(ChangeType.Template)); Assert.That(output.RightLines[4].Change, Is.EqualTo(ChangeType.None)); }
public void TestDeleteLine() { TextFileInformation tfi = new TextFileInformation(); tfi.NewGenFile = new TextFile("line 0\r\nline 1\r\nline 2"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.RightLines, Has.Count(3)); Assert.That(output.LeftLines, Has.Count(3)); output.RemoveLine(0); Assert.That(output.RightLines, Has.Count(2)); Assert.That(output.LeftLines, Has.Count(2)); Assert.That(output.RightLines[0].Text, Is.EqualTo("line 1")); Assert.That(output.LeftLines[0].Text, Is.EqualTo("line 1")); }
public override VisualDiffOutput GetDiffOutput() { ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(fileInformation); return diffUtility.ProcessMergeOutput(); }
public void TestExactCopy() { TextFileInformation tfi = new TextFileInformation(); tfi.NewGenFile = new TextFile("aklsdjflkjasdf"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.DiffType, Is.EqualTo(TypeOfDiff.ExactCopy)); Assert.That(output.RightLines, Has.Count(1)); Assert.That(output.LeftLines, Has.Count(1)); Assert.That(output.LeftLines[0].Text, Is.EqualTo(tfi.NewGenFile.GetContents())); Assert.That(output.RightLines[0].Text, Is.EqualTo(tfi.NewGenFile.GetContents())); }
public void TestToString() { TextFileInformation tfi = new TextFileInformation(); tfi.NewGenFile = new TextFile("line 0\r\nline 1\r\nline 2"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.ToString().Contains("Left Lines")); Assert.That(output.ToString().Contains("Right Lines")); Assert.That(output.ToString().IndexOf("line 0"), Is.Not.EqualTo(output.ToString().LastIndexOf("line 0"))); }
public void TestGetConflictBefore_And_After() { TextFileInformation tfi = new TextFileInformation(); tfi.NewGenFile = new TextFile("line 0\r\nline 10\r\nline 2\r\nline32\r\nline 4\r\nline54\r\nline6"); tfi.UserFile = new TextFile("line 0\r\nline 12\r\nline 2\r\nline35\r\nline 4\r\nline56\r\nline6"); tfi.PrevGenFile = new TextFile("line 0\r\nline 1\r\nline 2\r\nline3\r\nline 4\r\nline5\r\nline6"); tfi.IntelliMerge = IntelliMergeType.PlainText; tfi.RelativeFilePath = "text.txt"; ThreeWayVisualDiff diffUtility = new ThreeWayVisualDiff(tfi); VisualDiffOutput output = diffUtility.ProcessMergeOutput(); Assert.IsNotNull(output); Assert.That(output.RightLines, Has.Count(10)); Assert.That(output.LeftLines, Has.Count(10)); VisualDiffOutput.ConflictRange conflict; Assert.That(output.IsLineInConflict(1), Is.True); Assert.That(output.IsLineInConflict(1, out conflict), Is.True); Assert.That(conflict, Is.Not.Null); Assert.That(conflict.StartLineIndex, Is.EqualTo(1)); Assert.That(conflict.EndLineIndex, Is.EqualTo(3)); Assert.That(output.GetConflictAfter(1).StartLineIndex, Is.EqualTo(4)); Assert.That(output.GetConflictBefore(1).StartLineIndex, Is.EqualTo(7)); Assert.That(output.GetConflictAfter(4).StartLineIndex, Is.EqualTo(7)); Assert.That(output.GetConflictBefore(4).StartLineIndex, Is.EqualTo(1)); }