Exemple #1
0
        public void testMerge_WithPrefix()
        {
            global::GitSharp.Core.Ref a = newRef("refs/heads/A", ID_ONE);
            global::GitSharp.Core.Ref b = newRef("refs/heads/foo/bar/B", ID_TWO);
            global::GitSharp.Core.Ref c = newRef("refs/heads/foo/rab/C", ID_TWO);
            global::GitSharp.Core.Ref g = newRef("refs/heads/g", ID_ONE);
            packed = toList(a, b, c, g);

            RefMap map = new RefMap("refs/heads/foo/", packed, loose, resolved);

            Assert.AreEqual(2, map.size());

            Assert.AreSame(b, map.get("bar/B"));
            Assert.AreSame(c, map.get("rab/C"));
            Assert.IsNull(map.get("refs/heads/foo/bar/B"));
            Assert.IsNull(map.get("refs/heads/A"));

            Assert.IsTrue(map.containsKey("bar/B"));
            Assert.IsTrue(map.containsKey("rab/C"));
            Assert.IsFalse(map.containsKey("refs/heads/foo/bar/B"));
            Assert.IsFalse(map.containsKey("refs/heads/A"));

            IteratorBase <RefMap.Ent> itr = map.entrySet().iterator();

            RefMap.Ent ent;
            Assert.IsTrue(itr.hasNext());
            ent = itr.next();
            Assert.AreEqual("bar/B", ent.getKey());
            Assert.AreSame(b, ent.getValue());
            Assert.IsTrue(itr.hasNext());
            ent = itr.next();
            Assert.AreEqual("rab/C", ent.getKey());
            Assert.AreSame(c, ent.getValue());
            Assert.IsFalse(itr.hasNext());
        }
Exemple #2
0
        public void testEmpty_NoPrefix1()
        {
            RefMap map = new RefMap("", packed, loose, resolved);
            Assert.IsTrue(map.isEmpty()); // before size was computed
            Assert.AreEqual(0, map.size());
            Assert.IsTrue(map.isEmpty()); // after size was computed

            Assert.IsFalse(map.entrySet().iterator().hasNext());
            Assert.IsFalse(map.keySet().iterator().hasNext());
            Assert.IsFalse(map.containsKey("a"));
            Assert.IsNull(map.get("a"));
        }
Exemple #3
0
        public void testEmpty_NoPrefix2()
        {
            RefMap map = new RefMap();

            Assert.IsTrue(map.isEmpty()); // before size was computed
            Assert.AreEqual(0, map.size());
            Assert.IsTrue(map.isEmpty()); // after size was computed

            Assert.IsFalse(map.entrySet().iterator().hasNext());
            Assert.IsFalse(map.keySet().iterator().hasNext());
            Assert.IsFalse(map.containsKey("a"));
            Assert.IsNull(map.get("a"));
        }
Exemple #4
0
        public void testEmpty_WithPrefix()
        {
            global::GitSharp.Core.Ref master = newRef("refs/heads/master", ID_ONE);
            packed = toList(master);

            RefMap map = new RefMap("refs/tags/", packed, loose, resolved);

            Assert.IsTrue(map.isEmpty()); // before size was computed
            Assert.AreEqual(0, map.size());
            Assert.IsTrue(map.isEmpty()); // after size was computed

            Assert.IsFalse(map.entrySet().iterator().hasNext());
            Assert.IsFalse(map.keySet().iterator().hasNext());
        }
Exemple #5
0
        public void testEntryType()
        {
            global::GitSharp.Core.Ref a = newRef("refs/heads/A", ID_ONE);
            global::GitSharp.Core.Ref b = newRef("refs/heads/B", ID_TWO);

            packed = toList(a, b);

            RefMap map = new RefMap("refs/heads/", packed, loose, resolved);
            IteratorBase <RefMap.Ent> itr = map.entrySet().iterator();

            RefMap.Ent ent_a = itr.next();
            RefMap.Ent ent_b = itr.next();

            Assert.AreEqual(ent_a.GetHashCode(), "A".GetHashCode());
            Assert.IsTrue(ent_a.Equals(ent_a));
            Assert.IsFalse(ent_a.Equals(ent_b));

            Assert.AreEqual(a.ToString(), ent_a.ToString());
        }
Exemple #6
0
        public void testEntryTypeSet()
        {
            global::GitSharp.Core.Ref refA_one = newRef("refs/heads/A", ID_ONE);
            global::GitSharp.Core.Ref refA_two = newRef("refs/heads/A", ID_TWO);

            packed = toList(refA_one);

            RefMap map = new RefMap("refs/heads/", packed, loose, resolved);

            Assert.AreSame(refA_one, map.get("A"));

            RefMap.Ent ent = map.entrySet().iterator().next();
            Assert.AreEqual("A", ent.getKey());
            Assert.AreSame(refA_one, ent.getValue());

            Assert.AreSame(refA_one, ent.setValue(refA_two));
            Assert.AreSame(refA_two, ent.getValue());
            Assert.AreSame(refA_two, map.get("A"));
            Assert.AreEqual(1, map.size());
        }
Exemple #7
0
        public void testMerge_WithPrefix()
        {
            global::GitSharp.Core.Ref a = newRef("refs/heads/A", ID_ONE);
            global::GitSharp.Core.Ref b = newRef("refs/heads/foo/bar/B", ID_TWO);
            global::GitSharp.Core.Ref c = newRef("refs/heads/foo/rab/C", ID_TWO);
            global::GitSharp.Core.Ref g = newRef("refs/heads/g", ID_ONE);
            packed = toList(a, b, c, g);

            RefMap map = new RefMap("refs/heads/foo/", packed, loose, resolved);
            Assert.AreEqual(2, map.size());

            Assert.AreSame(b, map.get("bar/B"));
            Assert.AreSame(c, map.get("rab/C"));
            Assert.IsNull(map.get("refs/heads/foo/bar/B"));
            Assert.IsNull(map.get("refs/heads/A"));

            Assert.IsTrue(map.containsKey("bar/B"));
            Assert.IsTrue(map.containsKey("rab/C"));
            Assert.IsFalse(map.containsKey("refs/heads/foo/bar/B"));
            Assert.IsFalse(map.containsKey("refs/heads/A"));

            IteratorBase<RefMap.Ent> itr = map.entrySet().iterator();
            RefMap.Ent ent;
            Assert.IsTrue(itr.hasNext());
            ent = itr.next();
            Assert.AreEqual("bar/B", ent.getKey());
            Assert.AreSame(b, ent.getValue());
            Assert.IsTrue(itr.hasNext());
            ent = itr.next();
            Assert.AreEqual("rab/C", ent.getKey());
            Assert.AreSame(c, ent.getValue());
            Assert.IsFalse(itr.hasNext());
        }
Exemple #8
0
        public void testEntryTypeSet()
        {
            global::GitSharp.Core.Ref refA_one = newRef("refs/heads/A", ID_ONE);
            global::GitSharp.Core.Ref refA_two = newRef("refs/heads/A", ID_TWO);

            packed = toList(refA_one);

            RefMap map = new RefMap("refs/heads/", packed, loose, resolved);
            Assert.AreSame(refA_one, map.get("A"));

            RefMap.Ent ent = map.entrySet().iterator().next();
            Assert.AreEqual("A", ent.getKey());
            Assert.AreSame(refA_one, ent.getValue());

            Assert.AreSame(refA_one, ent.setValue(refA_two));
            Assert.AreSame(refA_two, ent.getValue());
            Assert.AreSame(refA_two, map.get("A"));
            Assert.AreEqual(1, map.size());
        }
Exemple #9
0
        public void testEntryType()
        {
            global::GitSharp.Core.Ref a = newRef("refs/heads/A", ID_ONE);
            global::GitSharp.Core.Ref b = newRef("refs/heads/B", ID_TWO);

            packed = toList(a, b);

            RefMap map = new RefMap("refs/heads/", packed, loose, resolved);
            IteratorBase<RefMap.Ent> itr = map.entrySet().iterator();
            RefMap.Ent ent_a = itr.next();
            RefMap.Ent ent_b = itr.next();

            Assert.AreEqual(ent_a.GetHashCode(), "A".GetHashCode());
            Assert.IsTrue(ent_a.Equals(ent_a));
            Assert.IsFalse(ent_a.Equals(ent_b));

            Assert.AreEqual(a.ToString(), ent_a.ToString());
        }
Exemple #10
0
        public void testEmpty_WithPrefix()
        {
            global::GitSharp.Core.Ref master = newRef("refs/heads/master", ID_ONE);
            packed = toList(master);

            RefMap map = new RefMap("refs/tags/", packed, loose, resolved);
            Assert.IsTrue(map.isEmpty()); // before size was computed
            Assert.AreEqual(0, map.size());
            Assert.IsTrue(map.isEmpty()); // after size was computed

            Assert.IsFalse(map.entrySet().iterator().hasNext());
            Assert.IsFalse(map.keySet().iterator().hasNext());
        }