public virtual void TestMerge_WithPrefix()
        {
            Ref a = NewRef("refs/heads/A", ID_ONE);
            Ref b = NewRef("refs/heads/foo/bar/B", ID_TWO);
            Ref c = NewRef("refs/heads/foo/rab/C", ID_TWO);
            Ref g = NewRef("refs/heads/g", ID_ONE);

            packed = ToList(a, b, c, g);
            RefMap map = new RefMap("refs/heads/foo/", packed, loose, resolved);

            NUnit.Framework.Assert.AreEqual(2, map.Count);
            NUnit.Framework.Assert.AreSame(b, map.Get("bar/B"));
            NUnit.Framework.Assert.AreSame(c, map.Get("rab/C"));
            NUnit.Framework.Assert.IsNull(map.Get("refs/heads/foo/bar/B"));
            NUnit.Framework.Assert.IsNull(map.Get("refs/heads/A"));
            NUnit.Framework.Assert.IsTrue(map.ContainsKey("bar/B"));
            NUnit.Framework.Assert.IsTrue(map.ContainsKey("rab/C"));
            NUnit.Framework.Assert.IsFalse(map.ContainsKey("refs/heads/foo/bar/B"));
            NUnit.Framework.Assert.IsFalse(map.ContainsKey("refs/heads/A"));
            Iterator <KeyValuePair <string, Ref> > itr = map.EntrySet().Iterator();
            KeyValuePair <string, Ref>             ent;

            NUnit.Framework.Assert.IsTrue(itr.HasNext());
            ent = itr.Next();
            NUnit.Framework.Assert.AreEqual("bar/B", ent.Key);
            NUnit.Framework.Assert.AreSame(b, ent.Value);
            NUnit.Framework.Assert.IsTrue(itr.HasNext());
            ent = itr.Next();
            NUnit.Framework.Assert.AreEqual("rab/C", ent.Key);
            NUnit.Framework.Assert.AreSame(c, ent.Value);
            NUnit.Framework.Assert.IsFalse(itr.HasNext());
        }
        public virtual void TestEmpty_NoPrefix2()
        {
            RefMap map = new RefMap();

            NUnit.Framework.Assert.IsTrue(map.IsEmpty());
            // before size was computed
            NUnit.Framework.Assert.AreEqual(0, map.Count);
            NUnit.Framework.Assert.IsTrue(map.IsEmpty());
            // after size was computed
            NUnit.Framework.Assert.IsFalse(map.EntrySet().Iterator().HasNext());
            NUnit.Framework.Assert.IsFalse(map.Keys.Iterator().HasNext());
            NUnit.Framework.Assert.IsFalse(map.ContainsKey("a"));
            NUnit.Framework.Assert.IsNull(map.Get("a"));
        }
        public virtual void TestEmpty_WithPrefix()
        {
            Ref master = NewRef("refs/heads/master", ID_ONE);

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

            NUnit.Framework.Assert.IsTrue(map.IsEmpty());
            // before size was computed
            NUnit.Framework.Assert.AreEqual(0, map.Count);
            NUnit.Framework.Assert.IsTrue(map.IsEmpty());
            // after size was computed
            NUnit.Framework.Assert.IsFalse(map.EntrySet().Iterator().HasNext());
            NUnit.Framework.Assert.IsFalse(map.Keys.Iterator().HasNext());
        }
        public virtual void TestEntryType()
        {
            Ref a = NewRef("refs/heads/A", ID_ONE);
            Ref b = NewRef("refs/heads/B", ID_TWO);

            packed = ToList(a, b);
            RefMap map = new RefMap("refs/heads/", packed, loose, resolved);
            Iterator <KeyValuePair <string, Ref> > itr   = map.EntrySet().Iterator();
            KeyValuePair <string, Ref>             ent_a = itr.Next();
            KeyValuePair <string, Ref>             ent_b = itr.Next();

//			NUnit.Framework.Assert.AreEqual(ent_a.GetHashCode(), "A".GetHashCode());
            NUnit.Framework.Assert.IsTrue(ent_a.Equals(ent_a));
            NUnit.Framework.Assert.IsFalse(ent_a.Equals(ent_b));
            NUnit.Framework.Assert.AreEqual(a.ToString(), ent_a.Value.ToString());
        }
示例#5
0
文件: RefMapTest.cs 项目: shoff/ngit
        public virtual void TestEntryTypeSet()
        {
            Ref refA_one = NewRef("refs/heads/A", ID_ONE);
            Ref refA_two = NewRef("refs/heads/A", ID_TWO);

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

            NUnit.Framework.Assert.AreSame(refA_one, map.Get("A"));
            KeyValuePair <string, Ref> ent = map.EntrySet().Iterator().Next();

            NUnit.Framework.Assert.AreEqual("A", ent.Key);
            NUnit.Framework.Assert.AreSame(refA_one, ent.Value);
//			NUnit.Framework.Assert.AreSame(refA_one, ent.SetValue(refA_two));
//			NUnit.Framework.Assert.AreSame(refA_two, ent.Value);
            NUnit.Framework.Assert.AreSame(refA_two, map.Get("A"));
            NUnit.Framework.Assert.AreEqual(1, map.Count);
        }
        public virtual void TestEntryTypeSet()
        {
            Ref refA_one = NewRef("refs/heads/A", ID_ONE);
            Ref refA_two = NewRef("refs/heads/A", ID_TWO);

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

            NUnit.Framework.Assert.AreSame(refA_one, map.Get("A"));
            KeyValuePair <string, Ref> ent = map.EntrySet().Iterator().Next();

            NUnit.Framework.Assert.AreEqual("A", ent.Key);
            NUnit.Framework.Assert.AreSame(refA_one, ent.Value);

            // FIXME: .NET returns an immutable KeyValuePair whereas Java
            // returns a mutable one. Therefore this test is invalid in .NET
            // No code does this internally (it's a compile error as SetValue does not exist)
            // so we are ok to comment this out.
//			NUnit.Framework.Assert.AreSame(refA_one, ent.SetValue(refA_two));
//			NUnit.Framework.Assert.AreSame(refA_two, ent.Value);
//			NUnit.Framework.Assert.AreEqual(refA_two, map.Get("A"));
//			NUnit.Framework.Assert.AreEqual(1, map.Count);
        }