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))); } }
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()); }