8000 Patch entry test coverage. · libgit2/libgit2sharp@acd6b59 · GitHub
[go: up one dir, main page]

Skip to content

Commit acd6b59

Browse files
committed
Patch entry test coverage.
1 parent 35b672d commit acd6b59

File tree

1 file changed

+44
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)
0