Пример #1
0
 /// <summary>Remove a repository from the cache.</summary>
 /// <remarks>
 /// Remove a repository from the cache.
 /// <p>
 /// Removes a repository from the cache, if it is still registered here,
 /// permitting it to close.
 /// </remarks>
 /// <param name="db">repository to unregister.</param>
 public static void Close(Repository db)
 {
     if (db.Directory != null)
     {
         RepositoryCache.FileKey key = RepositoryCache.FileKey.Exact(db.Directory, db.FileSystem
                                                                     );
         cache.UnregisterRepository(key);
     }
 }
Пример #2
0
        public virtual void TestCacheOpen()
        {
            RepositoryCache.FileKey loc = RepositoryCache.FileKey.Exact(db.Directory, db.FileSystem
                                                                        );
            Repository d2 = RepositoryCache.Open(loc);

            NUnit.Framework.Assert.AreNotSame(db, d2);
            NUnit.Framework.Assert.AreSame(d2, RepositoryCache.Open(RepositoryCache.FileKey.Exact
                                                                        (loc.GetFile(), db.FileSystem)));
            d2.Close();
            d2.Close();
        }
Пример #3
0
        public virtual void TestFileKeyOpenExisting()
        {
            Repository r;

            r = new RepositoryCache.FileKey(db.Directory, db.FileSystem).Open(true);
            NUnit.Framework.Assert.IsNotNull(r);
            NUnit.Framework.Assert.AreEqual(db.Directory, r.Directory);
            r.Close();
            r = new RepositoryCache.FileKey(db.Directory, db.FileSystem).Open(false);
            NUnit.Framework.Assert.IsNotNull(r);
            NUnit.Framework.Assert.AreEqual(db.Directory, r.Directory);
            r.Close();
        }
Пример #4
0
        public virtual void TestFileKeyOpenNew()
        {
            Repository n      = CreateBareRepository();
            FilePath   gitdir = n.Directory;

            n.Close();
            RecursiveDelete(gitdir);
            NUnit.Framework.Assert.IsFalse(gitdir.Exists());
            try
            {
                new RepositoryCache.FileKey(gitdir, db.FileSystem).Open(true);
                NUnit.Framework.Assert.Fail("incorrectly opened a non existant repository");
            }
            catch (RepositoryNotFoundException e)
            {
                NUnit.Framework.Assert.AreEqual("repository not found: " + gitdir, e.Message);
            }
            Repository o = new RepositoryCache.FileKey(gitdir, db.FileSystem).Open(false);

            NUnit.Framework.Assert.IsNotNull(o);
            NUnit.Framework.Assert.AreEqual(gitdir, o.Directory);
            NUnit.Framework.Assert.IsFalse(gitdir.Exists());
        }
Пример #5
0
		public virtual void TestFileKeyOpenExisting()
		{
			Repository r;
			r = new RepositoryCache.FileKey(db.Directory, db.FileSystem).Open(true);
			NUnit.Framework.Assert.IsNotNull(r);
			NUnit.Framework.Assert.AreEqual(db.Directory, r.Directory);
			r.Close();
			r = new RepositoryCache.FileKey(db.Directory, db.FileSystem).Open(false);
			NUnit.Framework.Assert.IsNotNull(r);
			NUnit.Framework.Assert.AreEqual(db.Directory, r.Directory);
			r.Close();
		}
Пример #6
0
		public virtual void TestFileKeyOpenNew()
		{
			Repository n = CreateBareRepository();
			FilePath gitdir = n.Directory;
			n.Close();
			RecursiveDelete(gitdir);
			NUnit.Framework.Assert.IsFalse(gitdir.Exists());
			try
			{
				new RepositoryCache.FileKey(gitdir, db.FileSystem).Open(true);
				NUnit.Framework.Assert.Fail("incorrectly opened a non existant repository");
			}
			catch (RepositoryNotFoundException e)
			{
				NUnit.Framework.Assert.AreEqual("repository not found: " + gitdir, e.Message);
			}
			Repository o = new RepositoryCache.FileKey(gitdir, db.FileSystem).Open(false);
			NUnit.Framework.Assert.IsNotNull(o);
			NUnit.Framework.Assert.AreEqual(gitdir, o.Directory);
			NUnit.Framework.Assert.IsFalse(gitdir.Exists());
		}