Пример #1
0
 public void testCacheOpen()
 {
     RepositoryCache.FileKey loc = RepositoryCache.FileKey.exact(db.Directory);
     Core.Repository         d2  = RepositoryCache.open(loc);
     Assert.AreNotSame(db, d2);
     Assert.AreSame(d2, RepositoryCache.open(RepositoryCache.FileKey.exact(loc.getFile())));
     d2.Close();
     d2.Close();
 }
Пример #2
0
        public void testFileKeyOpenNew()
        {
            Core.Repository n = createBareRepository();

            DirectoryInfo gitdir = n.Directory;

            n.Close();
            recursiveDelete(gitdir);
            Assert.IsFalse(gitdir.Exists);

            var e =
                AssertHelper.Throws <RepositoryNotFoundException>(() => new RepositoryCache.FileKey(gitdir).open(true));

            Assert.AreEqual("repository not found: " + gitdir, e.Message);

            using (Core.Repository o = new RepositoryCache.FileKey(gitdir).open(false))
            {
                Assert.IsNotNull(o);
                Assert.AreEqual(gitdir.FullName, o.Directory.FullName);
                Assert.IsFalse(gitdir.Exists);
            }
        }