Exemplo n.º 1
0
        public virtual void TestBuilder_ToString()
        {
            StringBuilder exp = new StringBuilder();

            exp.Append("[");
            exp.Append(REF_A);
            exp.Append(", ");
            exp.Append(REF_B);
            exp.Append("]");
            RefListBuilder <Ref> list = new RefListBuilder <Ref>();

            list.Add(REF_A);
            list.Add(REF_B);
            NUnit.Framework.Assert.AreEqual(exp.ToString(), list.ToString());
        }
Exemplo n.º 2
0
        public virtual void TestEmptyBuilder()
        {
            RefList <Ref> list = new RefListBuilder <Ref>().ToRefList();

            NUnit.Framework.Assert.AreEqual(0, list.Size());
            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"));
            NUnit.Framework.Assert.IsTrue(list.AsList().IsEmpty());
            NUnit.Framework.Assert.AreEqual("[]", list.ToString());
            // default array capacity should be 16, with no bounds checking.
            NUnit.Framework.Assert.IsNull(list.Get(16 - 1));
            try
            {
                list.Get(16);
                NUnit.Framework.Assert.Fail("default RefList should have 16 element array");
            }
            catch (IndexOutOfRangeException)
            {
            }
        }