本文整理汇总了C#中RefMap类的典型用法代码示例。如果您正苦于以下问题:C# RefMap类的具体用法?C# RefMap怎么用?C# RefMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RefMap类属于命名空间,在下文中一共展示了RefMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testEmpty_NoPrefix2
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"));
}
示例2: testClear
public void testClear()
{
global::GitSharp.Core.Ref master = newRef("refs/heads/master", ID_ONE);
loose = toList(master);
RefMap map = new RefMap("", packed, loose, resolved);
Assert.AreSame(master, map.get("refs/heads/master"));
map.clear();
Assert.IsNull(map.get("refs/heads/master"));
Assert.IsTrue(map.isEmpty());
Assert.AreEqual(0, map.size());
}
示例3: TestEmpty_NoPrefix1
public virtual void TestEmpty_NoPrefix1()
{
RefMap map = new RefMap(string.Empty, 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());
NUnit.Framework.Assert.IsFalse(map.ContainsKey("a"));
NUnit.Framework.Assert.IsNull(map.Get("a"));
}
示例4: testEntryTypeSet
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());
}
示例5: testEntryType
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());
}
示例6: TestMerge_WithPrefix
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());
}
示例7: testPut_WithPrefix
public void testPut_WithPrefix()
{
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"));
Assert.AreSame(refA_one, map.put("A", refA_two));
// map changed, but packed, loose did not
Assert.AreSame(refA_two, map.get("A"));
Assert.AreSame(refA_one, packed.get(0));
Assert.AreEqual(0, loose.size());
Assert.AreSame(refA_two, map.put("A", refA_one));
Assert.AreSame(refA_one, map.get("A"));
}
示例8: testPut_CollapseResolved
public void testPut_CollapseResolved()
{
global::GitSharp.Core.Ref master = newRef("refs/heads/master", ID_ONE);
global::GitSharp.Core.Ref headU = newRef("HEAD", "refs/heads/master");
global::GitSharp.Core.Ref headR = newRef("HEAD", master);
global::GitSharp.Core.Ref a = newRef("refs/heads/A", ID_ONE);
loose = toList(headU, master);
resolved = toList(headR);
RefMap map = new RefMap("", packed, loose, resolved);
Assert.IsNull(map.put(a.getName(), a));
Assert.AreSame(a, map.get(a.getName()));
Assert.AreSame(headR, map.get("HEAD"));
}
示例9: testMerge_WithPrefix
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());
}
示例10: testMerge_HeadMaster
public void testMerge_HeadMaster()
{
global::GitSharp.Core.Ref master = newRef("refs/heads/master", ID_ONE);
global::GitSharp.Core.Ref headU = newRef("HEAD", "refs/heads/master");
global::GitSharp.Core.Ref headR = newRef("HEAD", master);
loose = toList(headU, master);
resolved = toList(headR);
RefMap map = new RefMap("", packed, loose, resolved);
Assert.AreEqual(2, map.size());
Assert.IsFalse(map.isEmpty());
Assert.IsTrue(map.containsKey("refs/heads/master"));
Assert.AreSame(master, map.get("refs/heads/master"));
// resolved overrides loose given same name
Assert.AreSame(headR, map.get("HEAD"));
IteratorBase<global::GitSharp.Core.Ref> itr = map.values().iterator();
Assert.IsTrue(itr.hasNext());
Assert.AreSame(headR, itr.next());
Assert.IsTrue(itr.hasNext());
Assert.AreSame(master, itr.next());
Assert.IsFalse(itr.hasNext());
}
示例11: TestEntryType
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.ToString());
}
示例12: TestToString_WithPrefix
public virtual void TestToString_WithPrefix()
{
Ref a = NewRef("refs/heads/A", ID_ONE);
Ref b = NewRef("refs/heads/foo/B", ID_TWO);
Ref c = NewRef("refs/heads/foo/C", ID_TWO);
Ref g = NewRef("refs/heads/g", ID_ONE);
packed = ToList(a, b, c, g);
StringBuilder exp = new StringBuilder();
exp.Append("[");
exp.Append(b.ToString());
exp.Append(", ");
exp.Append(c.ToString());
exp.Append("]");
RefMap map = new RefMap("refs/heads/foo/", packed, loose, resolved);
NUnit.Framework.Assert.AreEqual(exp.ToString(), map.ToString());
}
示例13: TestToString_NoPrefix
public virtual void TestToString_NoPrefix()
{
Ref a = NewRef("refs/heads/A", ID_ONE);
Ref b = NewRef("refs/heads/B", ID_TWO);
packed = ToList(a, b);
StringBuilder exp = new StringBuilder();
exp.Append("[");
exp.Append(a.ToString());
exp.Append(", ");
exp.Append(b.ToString());
exp.Append("]");
RefMap map = new RefMap(string.Empty, packed, loose, resolved);
NUnit.Framework.Assert.AreEqual(exp.ToString(), map.ToString());
}
示例14: TestRemove
public virtual void TestRemove()
{
Ref master = NewRef("refs/heads/master", ID_ONE);
Ref headU = NewRef("HEAD", "refs/heads/master");
Ref headR = NewRef("HEAD", master);
packed = ToList(master);
loose = ToList(headU, master);
resolved = ToList(headR);
RefMap map = new RefMap(string.Empty, packed, loose, resolved);
NUnit.Framework.Assert.IsNull(Sharpen.Collections.Remove(map, "not.a.reference"));
NUnit.Framework.Assert.AreSame(master, Sharpen.Collections.Remove(map, "refs/heads/master"
));
NUnit.Framework.Assert.IsNull(map.Get("refs/heads/master"));
NUnit.Framework.Assert.AreSame(headR, Sharpen.Collections.Remove(map, "HEAD"));
NUnit.Framework.Assert.IsNull(map.Get("HEAD"));
NUnit.Framework.Assert.IsTrue(map.IsEmpty());
}
示例15: TestPut_CollapseResolved
public virtual void TestPut_CollapseResolved()
{
Ref master = NewRef("refs/heads/master", ID_ONE);
Ref headU = NewRef("HEAD", "refs/heads/master");
Ref headR = NewRef("HEAD", master);
Ref a = NewRef("refs/heads/A", ID_ONE);
loose = ToList(headU, master);
resolved = ToList(headR);
RefMap map = new RefMap(string.Empty, packed, loose, resolved);
NUnit.Framework.Assert.IsNull(map.Put(a.GetName(), a));
NUnit.Framework.Assert.AreSame(a, map.Get(a.GetName()));
NUnit.Framework.Assert.AreSame(headR, map.Get("HEAD"));
}