public void TestGetSetCreateRef() { var testObj = new object(); var testInst = new IndexedContainerRef <object>(10); Assert.AreEqual(10, testInst.Capacity); testInst.SetItem(5, testObj); Assert.AreEqual(testObj, testInst.GetItem(5)); for (int i = 0; i < 100; i++) { if (i == 5) { Assert.AreEqual(testObj, testInst.GetItemOrDefault(i)); object tmp = null; Assert.IsTrue(testInst.TryGetItem(i, out tmp)); Assert.AreEqual(testObj, tmp); } else { Assert.AreEqual(null, testInst.GetItemOrDefault(i)); object tmp = null; Assert.IsFalse(testInst.TryGetItem(i, out tmp)); } } }
public void TestResizeRef() { var testObj = new object(); var testInst = new IndexedContainerRef <object>(10); Assert.AreEqual(10, testInst.Capacity); testInst.SetItem(100, testObj); Assert.IsTrue(testInst.Capacity > 100); Assert.AreEqual(testObj, testInst.GetItem(100)); for (int i = 0; i < 200; i++) { if (i == 100) { Assert.AreEqual(testObj, testInst.GetItemOrDefault(i)); } else { Assert.AreEqual(null, testInst.GetItemOrDefault(i)); } } }