Esempio n. 1
0
        public virtual void TestIterable()
        {
            RefList <Ref> list = ToList(REF_A, REF_B, REF_c);
            int           idx  = 0;

            foreach (Ref @ref in list)
            {
                NUnit.Framework.Assert.AreSame(list.Get(idx++), @ref);
            }
            NUnit.Framework.Assert.AreEqual(3, idx);
            Iterator <Ref> i = RefList.EmptyList().Iterator();

            try
            {
                i.Next();
                NUnit.Framework.Assert.Fail("did not throw NoSuchElementException");
            }
            catch (NoSuchElementException)
            {
            }
            // expected
            i = list.Iterator();
            NUnit.Framework.Assert.IsTrue(i.HasNext());
            NUnit.Framework.Assert.AreSame(REF_A, i.Next());
            try
            {
                i.Remove();
                NUnit.Framework.Assert.Fail("did not throw UnsupportedOperationException");
            }
            catch (NotSupportedException)
            {
            }
        }
Esempio n. 2
0
        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)
            {
            }
        }