public virtual void TestSingleRevision() { Git git = new Git(db); string[] content = new string[] { "first", "second", "third" }; WriteTrashFile("file.txt", Join(content)); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit = git.Commit().SetMessage("create file").Call(); BlameCommand command = new BlameCommand(db); command.SetFilePath("file.txt"); BlameResult lines = command.Call(); NUnit.Framework.Assert.IsNotNull(lines); NUnit.Framework.Assert.AreEqual(3, lines.GetResultContents().Size()); for (int i = 0; i < 3; i++) { NUnit.Framework.Assert.AreEqual(commit, lines.GetSourceCommit(i)); NUnit.Framework.Assert.AreEqual(i, lines.GetSourceLine(i)); } }
public virtual void TestTwoRevisions() { Git git = new Git(db); string[] content1 = new string[] { "first", "second" }; WriteTrashFile("file.txt", Join(content1)); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit1 = git.Commit().SetMessage("create file").Call(); string[] content2 = new string[] { "first", "second", "third" }; WriteTrashFile("file.txt", Join(content2)); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit2 = git.Commit().SetMessage("create file").Call(); BlameCommand command = new BlameCommand(db); command.SetFilePath("file.txt"); BlameResult lines = command.Call(); NUnit.Framework.Assert.AreEqual(3, lines.GetResultContents().Size()); NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(0)); NUnit.Framework.Assert.AreEqual(0, lines.GetSourceLine(0)); NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(1)); NUnit.Framework.Assert.AreEqual(1, lines.GetSourceLine(1)); NUnit.Framework.Assert.AreEqual(commit2, lines.GetSourceCommit(2)); NUnit.Framework.Assert.AreEqual(2, lines.GetSourceLine(2)); }
public virtual void TestDeleteMiddleLines() { Git git = new Git(db); string[] content1 = new string[] { "a", "b", "c", "d", "e" }; string[] content2 = new string[] { "a", "c", "e" }; WriteTrashFile("file.txt", Join(content2)); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit1 = git.Commit().SetMessage("edit file").Call(); WriteTrashFile("file.txt", Join(content1)); git.Add().AddFilepattern("file.txt").Call(); git.Commit().SetMessage("edit file").Call(); WriteTrashFile("file.txt", Join(content2)); git.Add().AddFilepattern("file.txt").Call(); git.Commit().SetMessage("edit file").Call(); BlameCommand command = new BlameCommand(db); command.SetFilePath("file.txt"); BlameResult lines = command.Call(); NUnit.Framework.Assert.AreEqual(content2.Length, lines.GetResultContents().Size() ); NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(0)); NUnit.Framework.Assert.AreEqual(0, lines.GetSourceLine(0)); NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(1)); NUnit.Framework.Assert.AreEqual(1, lines.GetSourceLine(1)); NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(2)); NUnit.Framework.Assert.AreEqual(2, lines.GetSourceLine(2)); }
public virtual void TestMiddleClearAllLines() { Git git = new Git(db); string[] content1 = new string[] { "a", "b", "c" }; WriteTrashFile("file.txt", Join(content1)); git.Add().AddFilepattern("file.txt").Call(); git.Commit().SetMessage("edit file").Call(); WriteTrashFile("file.txt", string.Empty); git.Add().AddFilepattern("file.txt").Call(); git.Commit().SetMessage("create file").Call(); WriteTrashFile("file.txt", Join(content1)); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit3 = git.Commit().SetMessage("edit file").Call(); BlameCommand command = new BlameCommand(db); command.SetFilePath("file.txt"); BlameResult lines = command.Call(); NUnit.Framework.Assert.AreEqual(content1.Length, lines.GetResultContents().Size() ); NUnit.Framework.Assert.AreEqual(commit3, lines.GetSourceCommit(0)); NUnit.Framework.Assert.AreEqual(commit3, lines.GetSourceCommit(1)); NUnit.Framework.Assert.AreEqual(commit3, lines.GetSourceCommit(2)); }
public virtual void TestRename() { Git git = new Git(db); string[] content1 = new string[] { "a", "b", "c" }; WriteTrashFile("file.txt", Join(content1)); git.Add().AddFilepattern("file.txt").Call(); RevCommit commit1 = git.Commit().SetMessage("create file").Call(); WriteTrashFile("file1.txt", Join(content1)); git.Add().AddFilepattern("file1.txt").Call(); git.Rm().AddFilepattern("file.txt").Call(); git.Commit().SetMessage("moving file").Call(); string[] content2 = new string[] { "a", "b", "c2" }; WriteTrashFile("file1.txt", Join(content2)); git.Add().AddFilepattern("file1.txt").Call(); RevCommit commit3 = git.Commit().SetMessage("editing file").Call(); BlameCommand command = new BlameCommand(db); command.SetFollowFileRenames(true); command.SetFilePath("file1.txt"); BlameResult lines = command.Call(); NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(0)); NUnit.Framework.Assert.AreEqual(0, lines.GetSourceLine(0)); NUnit.Framework.Assert.AreEqual("file.txt", lines.GetSourcePath(0)); NUnit.Framework.Assert.AreEqual(commit1, lines.GetSourceCommit(1)); NUnit.Framework.Assert.AreEqual(1, lines.GetSourceLine(1)); NUnit.Framework.Assert.AreEqual("file.txt", lines.GetSourcePath(1)); NUnit.Framework.Assert.AreEqual(commit3, lines.GetSourceCommit(2)); NUnit.Framework.Assert.AreEqual(2, lines.GetSourceLine(2)); NUnit.Framework.Assert.AreEqual("file1.txt", lines.GetSourcePath(2)); }