예제 #1
0
        public virtual void TestClear()
        {
            ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId> m = new ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId
                                                                                    >();

            m.Add(id_1);
            NUnit.Framework.Assert.AreSame(id_1, m.Get(id_1));
            m.Clear();
            NUnit.Framework.Assert.IsTrue(m.IsEmpty());
            NUnit.Framework.Assert.AreEqual(0, m.Size());
            Iterator <ObjectIdOwnerMapTest.SubId> i = m.Iterator();

            NUnit.Framework.Assert.IsNotNull(i);
            NUnit.Framework.Assert.IsFalse(i.HasNext());
            NUnit.Framework.Assert.IsFalse(m.Contains(Id(1)));
        }
예제 #2
0
        public virtual void TestAddIfAbsentGrowsWithObjects()
        {
            int n = 16384;
            ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId> m = new ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId
                                                                                    >();

            m.Add(id_1);
            for (int i = 32; i < n; i++)
            {
                m.AddIfAbsent(new ObjectIdOwnerMapTest.SubId(Id(i)));
            }
            NUnit.Framework.Assert.AreEqual(n - 32 + 1, m.Size());
            NUnit.Framework.Assert.AreSame(id_1, m.Get(id_1.Copy()));
            for (int i_1 = 32; i_1 < n; i_1++)
            {
                NUnit.Framework.Assert.IsTrue(m.Contains(Id(i_1)));
            }
        }
예제 #3
0
        public virtual void TestAddGetAndContains()
        {
            ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId> m = new ObjectIdOwnerMap <ObjectIdOwnerMapTest.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));
        }