Exemplo n.º 1
0
        public virtual void TestEmptyMap()
        {
            ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId> m = new ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId
                                                                                    >();

            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)));
        }
Exemplo n.º 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)));
            }
        }
Exemplo n.º 3
0
        public virtual void TestAddIfAbsent()
        {
            ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId> m = new ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId
                                                                                    >();

            m.Add(id_1);
            NUnit.Framework.Assert.AreSame(id_1, m.AddIfAbsent(new ObjectIdOwnerMapTest.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 ObjectIdOwnerMapTest.SubId
                                                                     (id_a31)));
            NUnit.Framework.Assert.AreSame(id_b31, m.AddIfAbsent(new ObjectIdOwnerMapTest.SubId
                                                                     (id_b31)));
            NUnit.Framework.Assert.AreEqual(4, m.Size());
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        public virtual void TestIterator()
        {
            ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId> m = new ObjectIdOwnerMap <ObjectIdOwnerMapTest.SubId
                                                                                    >();

            m.Add(id_1);
            m.Add(id_2);
            m.Add(id_3);
            Iterator <ObjectIdOwnerMapTest.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)
            {
            }
        }
Exemplo n.º 6
0
 public _Iterator_223(ObjectIdOwnerMap <V> _enclosing)
 {
     this._enclosing = _enclosing;
 }