[TestCase("1.2.a..b.3.4", "1.2.a..b.a..b.3.4", "+b.+a.+.")] // This would be "+a.+.+b." without Indent-heuristic public async Task Indent_Heuristic_Is_Enabled(string content1, string content2, string expectPatch) { using (var temp = new TempRepository()) { var path = "foo.txt"; var commit1 = AddCommit(temp.Repository, path, content1.Replace('.', '\n')); var commit2 = AddCommit(temp.Repository, path, content2.Replace('.', '\n')); var target = new GitService(new RepositoryFacade()); var patch = await target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path); Assert.That(patch.Content.Replace('\n', '.'), Contains.Substring(expectPatch)); } }
public async Task One_File_Is_Modified(string content1, string content2) { using (var temp = new TempRepository()) { var path = "foo.txt"; var commit1 = AddCommit(temp.Repository, path, content1.Replace('.', '\n')); var commit2 = AddCommit(temp.Repository, path, content2.Replace('.', '\n')); var target = new GitService(new RepositoryFacade()); var treeChanges = await target.Compare(temp.Repository, commit1.Sha, commit2.Sha, false); Assert.That(treeChanges.Modified.FirstOrDefault()?.Path, Is.EqualTo(path)); } }
public void Path_Must_Not_Use_Windows_Directory_Separator() { using (var temp = new TempRepository()) { var path = @"dir\foo.txt"; var oldContent = "oldContent"; var newContent = "newContent"; var commit1 = AddCommit(temp.Repository, path, oldContent); var commit2 = AddCommit(temp.Repository, path, newContent); var target = new GitService(new RepositoryFacade()); Assert.ThrowsAsync <ArgumentException>(() => target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path)); } }
public async Task Path_Can_Use_Windows_Directory_Separator() { using (var temp = new TempRepository()) { var path = @"dir\foo.txt"; var oldContent = "oldContent"; var newContent = "newContent"; var commit1 = AddCommit(temp.Repository, path, oldContent); var commit2 = AddCommit(temp.Repository, path, newContent); var target = new GitService(new RepositoryFacade()); var patch = await target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path); var gitPath = Paths.ToGitPath(path); Assert.That(patch.Count(c => c.Path == gitPath), Is.EqualTo(1)); } }