Beispiel #1
0
        public virtual void TestEmptyMap()
        {
            ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId> m = new ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId
                                                                                             >();

            NUnit.Framework.Assert.IsTrue(m.IsEmpty());
            NUnit.Framework.Assert.AreEqual(0, m.Size());
            Iterator <ObjectIdSubclassMapTest.SubId> i = m.Iterator();

            NUnit.Framework.Assert.IsNotNull(i);
            NUnit.Framework.Assert.IsFalse(i.HasNext());
            NUnit.Framework.Assert.IsFalse(m.Contains(Id(1)));
        }
Beispiel #2
0
        public virtual void TestAddIfAbsentGrowsWithObjects()
        {
            ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId> m = new ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId
                                                                                             >();

            m.Add(id_1);
            for (int i = 32; i < 8000; i++)
            {
                m.AddIfAbsent(new ObjectIdSubclassMapTest.SubId(Id(i)));
            }
            NUnit.Framework.Assert.AreEqual(8000 - 32 + 1, m.Size());
            NUnit.Framework.Assert.AreSame(id_1, m.Get(id_1.Copy()));
            for (int i_1 = 32; i_1 < 8000; i_1++)
            {
                NUnit.Framework.Assert.IsTrue(m.Contains(Id(i_1)));
            }
        }
Beispiel #3
0
        public virtual void TestAddIfAbsent()
        {
            ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId> m = new ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId
                                                                                             >();

            m.Add(id_1);
            NUnit.Framework.Assert.AreSame(id_1, m.AddIfAbsent(new ObjectIdSubclassMapTest.SubId
                                                                   (id_1)));
            NUnit.Framework.Assert.AreEqual(1, m.Size());
            NUnit.Framework.Assert.AreSame(id_2, m.AddIfAbsent(id_2));
            NUnit.Framework.Assert.AreEqual(2, m.Size());
            NUnit.Framework.Assert.AreSame(id_a31, m.AddIfAbsent(id_a31));
            NUnit.Framework.Assert.AreSame(id_b31, m.AddIfAbsent(id_b31));
            NUnit.Framework.Assert.AreSame(id_a31, m.AddIfAbsent(new ObjectIdSubclassMapTest.SubId
                                                                     (id_a31)));
            NUnit.Framework.Assert.AreSame(id_b31, m.AddIfAbsent(new ObjectIdSubclassMapTest.SubId
                                                                     (id_b31)));
            NUnit.Framework.Assert.AreEqual(4, m.Size());
        }
Beispiel #4
0
        public virtual void TestAddGetAndContains()
        {
            ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId> m = new ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId
                                                                                             >();

            m.Add(id_1);
            m.Add(id_2);
            m.Add(id_3);
            m.Add(id_a31);
            m.Add(id_b31);
            NUnit.Framework.Assert.IsFalse(m.IsEmpty());
            NUnit.Framework.Assert.AreEqual(5, m.Size());
            NUnit.Framework.Assert.AreSame(id_1, m.Get(id_1));
            NUnit.Framework.Assert.AreSame(id_1, m.Get(Id(1)));
            NUnit.Framework.Assert.AreSame(id_1, m.Get(Id(1).Copy()));
            NUnit.Framework.Assert.AreSame(id_2, m.Get(Id(2).Copy()));
            NUnit.Framework.Assert.AreSame(id_3, m.Get(Id(3).Copy()));
            NUnit.Framework.Assert.AreSame(id_a31, m.Get(Id(31).Copy()));
            NUnit.Framework.Assert.AreSame(id_b31, m.Get(id_b31.Copy()));
            NUnit.Framework.Assert.IsTrue(m.Contains(id_1));
        }
Beispiel #5
0
        public virtual void TestIterator()
        {
            ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId> m = new ObjectIdSubclassMap <ObjectIdSubclassMapTest.SubId
                                                                                             >();

            m.Add(id_1);
            m.Add(id_2);
            m.Add(id_3);
            Iterator <ObjectIdSubclassMapTest.SubId> i = m.Iterator();

            NUnit.Framework.Assert.IsTrue(i.HasNext());
            NUnit.Framework.Assert.AreSame(id_1, i.Next());
            NUnit.Framework.Assert.IsTrue(i.HasNext());
            NUnit.Framework.Assert.AreSame(id_2, i.Next());
            NUnit.Framework.Assert.IsTrue(i.HasNext());
            NUnit.Framework.Assert.AreSame(id_3, i.Next());
            NUnit.Framework.Assert.IsFalse(i.HasNext());
            try
            {
                i.Next();
                NUnit.Framework.Assert.Fail("did not fail on next with no next");
            }
            catch (NoSuchElementException)
            {
            }
            // OK
            i = m.Iterator();
            NUnit.Framework.Assert.AreSame(id_1, i.Next());
            try
            {
                i.Remove();
                NUnit.Framework.Assert.Fail("did not fail on remove");
            }
            catch (NotSupportedException)
            {
            }
        }
 public _Iterator_190(ObjectIdSubclassMap <V> _enclosing)
 {
     this._enclosing = _enclosing;
 }