forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PatchEntryChangesFixture.cs
44 lines (41 loc) · 1.45 KB
/
PatchEntryChangesFixture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.IO;
using System.Linq;
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
namespace LibGit2Sharp.Tests
{
public class PatchEntryChangesFixture : BaseFixture
{
[Fact]
public void PatchEntryBasics()
{
// Init test repo
var path = SandboxStandardTestRepoGitDir();
string file = "numbers.txt";
// The repo
using (var repo = new Repository(path))
{
Tree rootCommitTree = repo.Lookup<Commit>("f8d44d7").Tree;
Tree commitTreeWithUpdatedFile = repo.Lookup<Commit>("ec9e401").Tree;
// Create patch by diffing
using (var patch = repo.Diff.Compare<Patch>(rootCommitTree, commitTreeWithUpdatedFile))
{
PatchEntryChanges entryChanges = patch[file];
Assert.Equal(2, entryChanges.LinesAdded);
Assert.Equal(1, entryChanges.LinesDeleted);
Assert.Equal(187, entryChanges.Patch.Length);
// Smoke test
Assert.Equal(Mode.NonExecutableFile, entryChanges.Mode);
Assert.Equal(new ObjectId("4625a3628cb78970c57e23a2fe2574514ba403c7"), entryChanges.Oid);
Assert.Equal(ChangeKind.Modified, entryChanges.Status);
Assert.Equal(file, entryChanges.OldPath);
Assert.Equal(Mode.NonExecutableFile, entryChanges.OldMode);
Assert.Equal(new ObjectId("7909961ae96accd75b6813d32e0fc1d6d52ec941"), entryChanges.OldOid);
}
}
}
}
}