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:
Diffstat (limited to 'LibGit2Sharp.Tests/InstantiatingARepository.cs')
-rw-r--r--LibGit2Sharp.Tests/InstantiatingARepository.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/InstantiatingARepository.cs b/LibGit2Sharp.Tests/InstantiatingARepository.cs
new file mode 100644
index 00000000..b78aff2b
--- /dev/null
+++ b/LibGit2Sharp.Tests/InstantiatingARepository.cs
@@ -0,0 +1,70 @@
+using System;
+using System.IO;
+using NUnit.Framework;
+
+namespace LibGit2Sharp.Tests
+{
+ [TestFixture]
+ public class InstantiatingARepository : ReadOnlyRepositoryFixtureBase
+ {
+ [Test]
+ public void ShouldThrowIfPassedANonValidGitDirectory()
+ {
+ var notAValidRepo = Path.GetTempPath();
+ Assert.Throws<NotAValidRepositoryException>(() => new Repository(notAValidRepo));
+ }
+
+ [Test]
+ public void ShouldThrowIfPassedANonExistingFolder()
+ {
+ var notAValidRepo = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString());
+ Assert.Throws<NotAValidRepositoryException>(() => new Repository(notAValidRepo));
+ }
+
+ [Test]
+ public void ShouldAcceptPlatormNativeRelativePath()
+ {
+ string repoPath = PathToRepository.Replace('/', Path.DirectorySeparatorChar);
+
+ AssertRepositoryPath(repoPath);
+ }
+
+ [Test]
+ public void ShouldAcceptPlatormNativeAbsolutePath()
+ {
+ string repoPath = Path.GetFullPath(PathToRepository);
+
+ AssertRepositoryPath(repoPath);
+ }
+
+ [Test]
+ public void ShouldAcceptPlatormNativeRelativePathWithATrailingDirectorySeparatorChar()
+ {
+ string repoPath = PathToRepository.Replace('/', Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;
+
+ AssertRepositoryPath(repoPath);
+ }
+
+ [Test]
+ public void ShouldAcceptPlatormNativeAbsolutePathWithATrailingDirectorySeparatorChar()
+ {
+ string repoPath = Path.GetFullPath(PathToRepository) + Path.DirectorySeparatorChar;
+
+ AssertRepositoryPath(repoPath);
+ }
+
+ private static void AssertRepositoryPath(string repoPath)
+ {
+ var expected = new DirectoryInfo(repoPath);
+
+ DirectoryInfo current;
+
+ using (var repo = new Repository(repoPath))
+ {
+ current = new DirectoryInfo(repo.Details.RepositoryDirectory);
+ }
+
+ Assert.AreEqual(expected, current);
+ }
+ }
+} \ No newline at end of file