当前位置: 首页>>代码示例>>C#>>正文


C# RefMap.Get方法代码示例

本文整理汇总了C#中RefMap.Get方法的典型用法代码示例。如果您正苦于以下问题:C# RefMap.Get方法的具体用法?C# RefMap.Get怎么用?C# RefMap.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RefMap的用法示例。


在下文中一共展示了RefMap.Get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEmpty_NoPrefix2

		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"));
		}
开发者ID:shoff,项目名称:ngit,代码行数:13,代码来源:RefMapTest.cs

示例2: 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());
		}
开发者ID:shoff,项目名称:ngit,代码行数:17,代码来源:RefMapTest.cs

示例3: TestEntryTypeSet

		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);
		}
开发者ID:shoff,项目名称:ngit,代码行数:15,代码来源:RefMapTest.cs

示例4: TestPut_WithPrefix

		public virtual void TestPut_WithPrefix()
		{
			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"));
			NUnit.Framework.Assert.AreSame(refA_one, map.Put("A", refA_two));
			// map changed, but packed, loose did not
			NUnit.Framework.Assert.AreSame(refA_two, map.Get("A"));
			NUnit.Framework.Assert.AreSame(refA_one, packed.Get(0));
			NUnit.Framework.Assert.AreEqual(0, loose.Size());
			NUnit.Framework.Assert.AreSame(refA_two, map.Put("A", refA_one));
			NUnit.Framework.Assert.AreSame(refA_one, map.Get("A"));
		}
开发者ID:shoff,项目名称:ngit,代码行数:15,代码来源:RefMapTest.cs

示例5: 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"));
		}
开发者ID:shoff,项目名称:ngit,代码行数:13,代码来源:RefMapTest.cs

示例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());
		}
开发者ID:shoff,项目名称:ngit,代码行数:29,代码来源:RefMapTest.cs

示例7: TestMerge_PackedLooseLoose

		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());
		}
开发者ID:shoff,项目名称:ngit,代码行数:24,代码来源:RefMapTest.cs

示例8: TestMerge_HeadMaster

		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());
		}
开发者ID:shoff,项目名称:ngit,代码行数:21,代码来源:RefMapTest.cs

示例9: TestClear

		public virtual void TestClear()
		{
			Ref master = NewRef("refs/heads/master", ID_ONE);
			loose = ToList(master);
			RefMap map = new RefMap(string.Empty, packed, loose, resolved);
			NUnit.Framework.Assert.AreSame(master, map.Get("refs/heads/master"));
			map.Clear();
			NUnit.Framework.Assert.IsNull(map.Get("refs/heads/master"));
			NUnit.Framework.Assert.IsTrue(map.IsEmpty());
			NUnit.Framework.Assert.AreEqual(0, map.Count);
		}
开发者ID:shoff,项目名称:ngit,代码行数:11,代码来源:RefMapTest.cs

示例10: TestEntryTypeSet

        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);
        }
开发者ID:gaijenbon,项目名称:ngit,代码行数:20,代码来源:RefMapTest.cs


注:本文中的RefMap.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。