public virtual void TestEventCountingSeveralImagesOneImageToPdfEvent() { String imgPath = TEST_IMAGES_DIRECTORY + "numbers_01.jpg"; FileInfo file = new FileInfo(imgPath); EventCountingTest.TestEventCounter eventCounter = new EventCountingTest.TestEventCounter(); IEventCounterFactory factory = new SimpleEventCounterFactory(eventCounter); EventCounterHandler.GetInstance().Register(factory); try { DoImageToPdfOcr(tesseractReader, JavaUtil.ArraysAsList(file, file)); NUnit.Framework.Assert.AreEqual(1, eventCounter.GetEvents().Count); NUnit.Framework.Assert.AreSame(PdfOcrTesseract4Event.TESSERACT4_IMAGE_TO_PDF, eventCounter.GetEvents()[0]); NUnit.Framework.Assert.IsNull(eventCounter.GetMetaInfos()[0]); } finally { EventCounterHandler.GetInstance().Unregister(factory); } }
public virtual void TestEventCountingImageEventCustomMetaInfo() { String imgPath = TEST_IMAGES_DIRECTORY + "numbers_01.jpg"; FileInfo file = new FileInfo(imgPath); EventCountingTest.TestEventCounter eventCounter = new EventCountingTest.TestEventCounter(); IEventCounterFactory factory = new SimpleEventCounterFactory(eventCounter); EventCounterHandler.GetInstance().Register(factory); try { tesseractReader.SetThreadLocalMetaInfo(new TestMetaInfo()); DoImageOcr(tesseractReader, file); NUnit.Framework.Assert.AreEqual(1, eventCounter.GetEvents().Count); NUnit.Framework.Assert.AreSame(PdfOcrTesseract4Event.TESSERACT4_IMAGE_OCR, eventCounter.GetEvents()[0]); NUnit.Framework.Assert.IsTrue(eventCounter.GetMetaInfos()[0] is TestMetaInfo); } finally { EventCounterHandler.GetInstance().Unregister(factory); tesseractReader.SetThreadLocalMetaInfo(null); } }