Exemple #1
0
        public void testRemoveMakesEmpty()
        {
            RefList <global::GitSharp.Core.Ref> one = toList(REF_A);
            RefList <global::GitSharp.Core.Ref> two = one.remove(1);

            Assert.AreNotSame(one, two);
            Assert.AreSame(two, RefList <global::GitSharp.Core.Ref> .emptyList());
        }
Exemple #2
0
        protected void setUp()
        {
            packed = RefList <global::GitSharp.Core.Ref> .emptyList();

            loose = RefList <global::GitSharp.Core.Ref> .emptyList();

            resolved = RefList <global::GitSharp.Core.Ref> .emptyList();
        }
        public RefDirectory(Repository db)
        {
            parent         = db;
            gitDir         = db.Directory;
            refsDir        = PathUtil.CombineDirectoryPath(gitDir, Constants.R_REFS);
            logsDir        = PathUtil.CombineDirectoryPath(gitDir, Constants.LOGS);
            logsRefsDir    = PathUtil.CombineDirectoryPath(gitDir, Constants.LOGS + Path.DirectorySeparatorChar + Constants.R_REFS);
            packedRefsFile = PathUtil.CombineFilePath(gitDir, Constants.PACKED_REFS);

            looseRefs.set(RefList <LooseRef> .emptyList());
            packedRefs.set(PackedRefList.NO_PACKED_REFS);
        }
Exemple #4
0
        public void testEmpty()
        {
            RefList <global::GitSharp.Core.Ref> list = RefList <global::GitSharp.Core.Ref> .emptyList();

            Assert.AreEqual(0, list.size());
            Assert.IsTrue(list.isEmpty());
            Assert.IsFalse(list.iterator().hasNext());
            Assert.AreEqual(-1, list.find("a"));
            Assert.AreEqual(-1, list.find("z"));
            Assert.IsFalse(list.contains("a"));
            Assert.IsNull(list.get("a"));
            try
            {
                list.get(0);
                Assert.Fail("RefList.emptyList should have 0 element array");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }
        }
Exemple #5
0
        public void testIterable()
        {
            RefList <global::GitSharp.Core.Ref> list = toList(REF_A, REF_B, REF_c);

            int idx = 0;

            foreach (global::GitSharp.Core.Ref @ref in list)
            {
                Assert.AreSame(list.get(idx++), @ref);
            }
            Assert.AreEqual(3, idx);

            var i = RefList <global::GitSharp.Core.Ref> .emptyList().iterator();

            try
            {
                i.next();
                Assert.Fail("did not throw NoSuchElementException");
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }

            i = list.iterator();
            Assert.IsTrue(i.hasNext());
            Assert.AreSame(REF_A, i.next());
            try
            {
                i.remove();
                Assert.Fail("did not throw UnsupportedOperationException");
            }
            catch (NotSupportedException)
            {
                // expected
            }
        }
 public void rescan()
 {
     looseRefs.set(RefList <LooseRef> .emptyList());
     packedRefs.set(PackedRefList.NO_PACKED_REFS);
 }