Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-11-21 17:49:26 +0400
committernulltoken <emeric.fermas@gmail.com>2011-11-28 23:36:13 +0400
commit2a4ac3cc787f08ace9e6cf7d8cfcf99a623c90d1 (patch)
tree052e5544f46e74a033f3d307174415e07424e1b2 /LibGit2Sharp.Tests/IndexFixture.cs
parent524f56f094dad402f4ab30b8973cb01216870e5f (diff)
Enforce Index.Move() test coverage
Diffstat (limited to 'LibGit2Sharp.Tests/IndexFixture.cs')
-rw-r--r--LibGit2Sharp.Tests/IndexFixture.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs
index c6ed5aad..cf181f93 100644
--- a/LibGit2Sharp.Tests/IndexFixture.cs
+++ b/LibGit2Sharp.Tests/IndexFixture.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
@@ -399,6 +400,62 @@ namespace LibGit2Sharp.Tests
}
}
+ [TestCase("README", FileStatus.Unaltered, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
+ [TestCase("new_tracked_file.txt", FileStatus.Added, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Nonexistent, FileStatus.Staged)]
+ [TestCase("modified_staged_file.txt", FileStatus.Staged, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
+ [TestCase("modified_unstaged_file.txt", FileStatus.Modified, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)]
+ public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileStatus sourceStatus, string destPath, FileStatus destStatus, FileStatus sourcePostStatus, FileStatus destPostStatus)
+ {
+ TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
+ using (var repo = new Repository(path.RepositoryPath))
+ {
+ repo.Index.RetrieveStatus(sourcePath).ShouldEqual(sourceStatus);
+ repo.Index.RetrieveStatus(destPath).ShouldEqual(destStatus);
+
+ repo.Index.Move(sourcePath, destPath);
+
+ repo.Index.RetrieveStatus(sourcePath).ShouldEqual(sourcePostStatus);
+ repo.Index.RetrieveStatus(destPath).ShouldEqual(destPostStatus);
+ }
+ }
+
+ [TestCase("README", FileStatus.Unaltered, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ [TestCase("new_tracked_file.txt", FileStatus.Added, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ [TestCase("modified_staged_file.txt", FileStatus.Staged, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ [TestCase("modified_unstaged_file.txt", FileStatus.Modified, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
+ public void MovingOverAnExistingFileThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
+ {
+ InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
+ }
+
+ [TestCase("new_untracked_file.txt", FileStatus.Untracked, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
+ {
+ InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
+ }
+
+ [TestCase("deleted_unstaged_file.txt", FileStatus.Missing, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ [TestCase("deleted_staged_file.txt", FileStatus.Removed, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ [TestCase("i_dont_exist.txt", FileStatus.Nonexistent, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
+ public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
+ {
+ InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
+ }
+
+ private static void InvalidMoveUseCases(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
+ {
+ using (var repo = new Repository(StandardTestRepoPath))
+ {
+ repo.Index.RetrieveStatus(sourcePath).ShouldEqual(sourceStatus);
+
+ foreach (var destPath in destPaths)
+ {
+ string path = destPath;
+ Assert.Throws<LibGit2Exception>(() => repo.Index.Move(sourcePath, path));
+ }
+ }
+ }
+
[Test]
public void CanRemoveAFile()
{