public virtual void TestContains() { NUnit.Framework.Assert.IsTrue(underlying.Contains("foo1")); NUnit.Framework.Assert.IsFalse(underlying.Contains("foo5")); NUnit.Framework.Assert.IsFalse(underlying.Contains("foo7")); NUnit.Framework.Assert.IsTrue(spillover.Contains("foo1")); NUnit.Framework.Assert.IsTrue(spillover.Contains("foo5")); NUnit.Framework.Assert.IsFalse(spillover.Contains("foo7")); }
public virtual void TestUnmodifiableViewEtc() { IList <string> list = new List <string>(); list.Add("A"); list.Add("B"); list.Add("A"); list.Add("C"); HashIndex <string> index4 = new HashIndex <string>(list); HashIndex <string> index5 = new HashIndex <string>(); Sharpen.Collections.AddAll(index5, list); NUnit.Framework.Assert.AreEqual("Equality failure", index4, index5); index5.AddToIndex("D"); index5.AddToIndex("E"); index5.IndexOf("F"); Sharpen.Collections.AddAll(index5, list); NUnit.Framework.Assert.AreEqual(5, index5.Count); NUnit.Framework.Assert.AreEqual(3, index4.Count); NUnit.Framework.Assert.IsTrue(index4.Contains("A")); NUnit.Framework.Assert.AreEqual(0, index4.IndexOf("A")); NUnit.Framework.Assert.AreEqual(1, index4.IndexOf("B")); NUnit.Framework.Assert.AreEqual(2, index4.IndexOf("C")); NUnit.Framework.Assert.AreEqual("A", index4.Get(0)); IIndex <string> index4u = index4.UnmodifiableView(); NUnit.Framework.Assert.AreEqual(3, index4u.Size()); NUnit.Framework.Assert.IsTrue(index4u.Contains("A")); NUnit.Framework.Assert.AreEqual(0, index4u.IndexOf("A")); NUnit.Framework.Assert.AreEqual(1, index4u.IndexOf("B")); NUnit.Framework.Assert.AreEqual(2, index4u.IndexOf("C")); NUnit.Framework.Assert.AreEqual("A", index4u.Get(0)); NUnit.Framework.Assert.AreEqual(-1, index4u.AddToIndex("D")); bool okay = false; try { index4u.Unlock(); } catch (NotSupportedException) { okay = true; } finally { NUnit.Framework.Assert.IsTrue(okay); } }