public void Remove_Test() { int generation = 1; PDFXRefTable target = new XRefTableProxy(generation); int count = target.ReferenceCount; PDFIndirectObject obj = new PDFIndirectObject(this); int actual = target.Append(obj); PDFIndirectObject obj2 = new PDFIndirectObject(this); actual = target.Append(obj2); //And check that it is in the list of references Assert.AreEqual(count + 2, target.ReferenceCount); Assert.IsTrue(target.Contains(obj2)); //XRef tables should not actualy remove entries, but replace the cell with an empty/deleted reference. target.Delete(obj2); Assert.AreEqual(count + 2, target.ReferenceCount); Assert.IsTrue(target.Contains(obj2)); IIndirectObject removed = target[count + 1].Reference; Assert.IsNotNull(removed); Assert.IsTrue(removed.Deleted); obj.Dispose(); obj2.Dispose(); }
public void Add_Test() { PDFIndirectObject obj = new PDFIndirectObject(this); int generation = 1; PDFXRefTable target = new XRefTableProxy(generation); int count = target.ReferenceCount; int expected = 1; //Should return 1 as the first item. int actual; actual = target.Append(obj); Assert.AreEqual(expected, actual); //Check that it has set the IndirectObjects' values too. Assert.AreEqual(target.Generation, obj.Generation); Assert.AreEqual(actual, obj.Number); Assert.AreEqual(-1L, obj.Offset); //And check that it is in the list of references Assert.AreEqual(count + 1, target.ReferenceCount); Assert.IsTrue(target.Contains(obj)); //Add another and test PDFIndirectObject obj2 = new PDFIndirectObject(this); expected = 2; actual = target.Append(obj); Assert.AreEqual(expected, actual); //Check that it has set the IndirectObjects' values too. Assert.AreEqual(target.Generation, obj.Generation); Assert.AreEqual(actual, obj.Number); Assert.AreEqual(-1L, obj.Offset); //And check that it is in the list of references Assert.AreEqual(count + 2, target.ReferenceCount); Assert.IsTrue(target.Contains(obj)); obj.Dispose(); obj2.Dispose(); }