コード例 #1
0
ファイル: RefListTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestAddToMiddleOfListByInsertionPosition()
        {
            RefList <Ref> one = ToList(REF_A, REF_c);

            NUnit.Framework.Assert.AreEqual(-2, one.Find(REF_B.GetName()));
            RefList <Ref> two = one.Add(one.Find(REF_B.GetName()), REF_B);

            NUnit.Framework.Assert.AreNotSame(one, two);
            // one is not modified, but two is
            NUnit.Framework.Assert.AreEqual(2, one.Size());
            NUnit.Framework.Assert.AreSame(REF_A, one.Get(0));
            NUnit.Framework.Assert.AreSame(REF_c, one.Get(1));
            NUnit.Framework.Assert.AreEqual(3, two.Size());
            NUnit.Framework.Assert.AreSame(REF_A, two.Get(0));
            NUnit.Framework.Assert.AreSame(REF_B, two.Get(1));
            NUnit.Framework.Assert.AreSame(REF_c, two.Get(2));
        }
コード例 #2
0
ファイル: RefListTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestEmpty()
        {
            RefList <Ref> list = RefList.EmptyList();

            NUnit.Framework.Assert.AreEqual(0, list.Size());
            NUnit.Framework.Assert.IsTrue(list.IsEmpty());
            NUnit.Framework.Assert.IsFalse(list.Iterator().HasNext());
            NUnit.Framework.Assert.AreEqual(-1, list.Find("a"));
            NUnit.Framework.Assert.AreEqual(-1, list.Find("z"));
            NUnit.Framework.Assert.IsFalse(list.Contains("a"));
            NUnit.Framework.Assert.IsNull(list.Get("a"));
            try
            {
                list.Get(0);
                NUnit.Framework.Assert.Fail("RefList.emptyList should have 0 element array");
            }
            catch (IndexOutOfRangeException)
            {
            }
        }
コード例 #3
0
ファイル: RefListTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestFindContainsGet()
        {
            RefList <Ref> list = ToList(REF_A, REF_B, REF_c);

            NUnit.Framework.Assert.AreEqual(0, list.Find("A"));
            NUnit.Framework.Assert.AreEqual(1, list.Find("B"));
            NUnit.Framework.Assert.AreEqual(2, list.Find("c"));
            NUnit.Framework.Assert.AreEqual(-1, list.Find("0"));
            NUnit.Framework.Assert.AreEqual(-2, list.Find("AB"));
            NUnit.Framework.Assert.AreEqual(-3, list.Find("a"));
            NUnit.Framework.Assert.AreEqual(-4, list.Find("z"));
            NUnit.Framework.Assert.AreSame(REF_A, list.Get("A"));
            NUnit.Framework.Assert.AreSame(REF_B, list.Get("B"));
            NUnit.Framework.Assert.AreSame(REF_c, list.Get("c"));
            NUnit.Framework.Assert.IsNull(list.Get("AB"));
            NUnit.Framework.Assert.IsNull(list.Get("z"));
            NUnit.Framework.Assert.IsTrue(list.Contains("A"));
            NUnit.Framework.Assert.IsTrue(list.Contains("B"));
            NUnit.Framework.Assert.IsTrue(list.Contains("c"));
            NUnit.Framework.Assert.IsFalse(list.Contains("AB"));
            NUnit.Framework.Assert.IsFalse(list.Contains("z"));
        }