public virtual void ThrowErrorTest() { NUnit.Framework.Assert.That(() => { RandomAccessSourceFactory factory = new RandomAccessSourceFactory(); PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.CreateSource("/Name1".GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1 )))); tok.ThrowError(iText.IO.IOException.ErrorAtFilePointer1, 0); } , NUnit.Framework.Throws.InstanceOf <iText.IO.IOException>().With.Message.EqualTo(MessageFormatUtil.Format(iText.IO.IOException.ErrorAtFilePointer1, 0))) ; }