Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 286d287

Browse files
committed
Add Path_Can_Use_Windows_Directory_Separator test
1 parent cd67be2 commit 286d287

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

test/GitHub.Exports.UnitTests/GitServiceIntegrationTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using GitHub.Primitives;
67
using GitHub.Services;
78
using LibGit2Sharp;
89
using NUnit.Framework;
@@ -61,7 +62,7 @@ public async Task One_File_Is_Modified(string content1, string content2)
6162

6263

6364
[Test]
64-
public void Path_Must_Not_Use_Windows_Directory_Separator()
65+
public async Task Path_Can_Use_Windows_Directory_Separator()
6566
{
6667
using (var temp = new TempRepository())
6768
{
@@ -72,8 +73,10 @@ public void Path_Must_Not_Use_Windows_Directory_Separator()
7273
var commit2 = AddCommit(temp.Repository, path, newContent);
7374
var target = new GitService(new RepositoryFacade());
7475

75-
Assert.ThrowsAsync<ArgumentException>(() =>
76-
target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path));
76+
var patch = await target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path);
77+
78+
var gitPath = Paths.ToGitPath(path);
79+
Assert.That(patch.Count(c => c.Path == gitPath), Is.EqualTo(1));
7780
}
7881
}
7982
}
@@ -134,7 +137,7 @@ public async Task Can_Handle_Renames(string oldPath, string oldContent, string n
134137
}
135138

136139
[Test]
137-
public void Path_Must_Not_Use_Windows_Directory_Separator()
140+
public async Task Path_Can_Use_Windows_Directory_Separator()
138141
{
139142
using (var temp = new TempRepository())
140143
{
@@ -146,8 +149,10 @@ public void Path_Must_Not_Use_Windows_Directory_Separator()
146149
var contentBytes = new UTF8Encoding(false).GetBytes(newContent);
147150
var target = new GitService(new RepositoryFacade());
148151

149-
Assert.ThrowsAsync<ArgumentException>(() =>
150-
target.CompareWith(temp.Repository, commit1.Sha, commit2.Sha, path, contentBytes));
152+
var contentChanges = await target.CompareWith(temp.Repository, commit1.Sha, commit2.Sha, path, contentBytes);
153+
154+
Assert.That(contentChanges.LinesAdded, Is.EqualTo(1));
155+
Assert.That(contentChanges.LinesDeleted, Is.EqualTo(1));
151156
}
152157
}
153158
}

0 commit comments

Comments
 (0)