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 TestMerge_PackedLooseLoose() { Ref refA = NewRef("A", ID_ONE); Ref refB_ONE = NewRef("B", ID_ONE); Ref refB_TWO = NewRef("B", ID_TWO); Ref refc = NewRef("c", ID_ONE); packed = ToList(refA, refB_ONE); loose = ToList(refB_TWO, refc); RefMap map = new RefMap(string.Empty, packed, loose, resolved); NUnit.Framework.Assert.AreEqual(3, map.Count); NUnit.Framework.Assert.IsFalse(map.IsEmpty()); NUnit.Framework.Assert.IsTrue(map.ContainsKey(refA.GetName())); NUnit.Framework.Assert.AreSame(refA, map.Get(refA.GetName())); // loose overrides packed given same name NUnit.Framework.Assert.AreSame(refB_TWO, map.Get(refB_ONE.GetName())); Iterator <Ref> itr = map.Values.Iterator(); NUnit.Framework.Assert.IsTrue(itr.HasNext()); NUnit.Framework.Assert.AreSame(refA, itr.Next()); NUnit.Framework.Assert.IsTrue(itr.HasNext()); NUnit.Framework.Assert.AreSame(refB_TWO, itr.Next()); NUnit.Framework.Assert.IsTrue(itr.HasNext()); NUnit.Framework.Assert.AreSame(refc, itr.Next()); 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 TestMerge_HeadMaster() { Ref master = NewRef("refs/heads/master", ID_ONE); Ref headU = NewRef("HEAD", "refs/heads/master"); Ref headR = NewRef("HEAD", master); loose = ToList(headU, master); resolved = ToList(headR); RefMap map = new RefMap(string.Empty, packed, loose, resolved); NUnit.Framework.Assert.AreEqual(2, map.Count); NUnit.Framework.Assert.IsFalse(map.IsEmpty()); NUnit.Framework.Assert.IsTrue(map.ContainsKey("refs/heads/master")); NUnit.Framework.Assert.AreSame(master, map.Get("refs/heads/master")); // resolved overrides loose given same name NUnit.Framework.Assert.AreSame(headR, map.Get("HEAD")); Iterator <Ref> itr = map.Values.Iterator(); NUnit.Framework.Assert.IsTrue(itr.HasNext()); NUnit.Framework.Assert.AreSame(headR, itr.Next()); NUnit.Framework.Assert.IsTrue(itr.HasNext()); NUnit.Framework.Assert.AreSame(master, itr.Next()); NUnit.Framework.Assert.IsFalse(itr.HasNext()); }