public virtual void TestEventCountingTwoPdfEvents() { 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)); DoImageToPdfOcr(tesseractReader, JavaUtil.ArraysAsList(file)); NUnit.Framework.Assert.AreEqual(2, eventCounter.GetEvents().Count); for (int i = 0; i < eventCounter.GetEvents().Count; i++) { NUnit.Framework.Assert.AreSame(PdfOcrTesseract4Event.TESSERACT4_IMAGE_TO_PDF, eventCounter.GetEvents()[i]); NUnit.Framework.Assert.IsNull(eventCounter.GetMetaInfos()[i]); } } finally { EventCounterHandler.GetInstance().Unregister(factory); } }
public virtual void TestEventCountingImageEvent() { 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 { 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.IsNull(eventCounter.GetMetaInfos()[0]); } finally { EventCounterHandler.GetInstance().Unregister(factory); } }
public virtual void TestEventCountingPdfEventCustomMetaInfo() { 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()); DoImageToPdfOcr(tesseractReader, JavaUtil.ArraysAsList(file)); NUnit.Framework.Assert.AreEqual(1, eventCounter.GetEvents().Count); NUnit.Framework.Assert.AreSame(PdfOcrTesseract4Event.TESSERACT4_IMAGE_TO_PDF, eventCounter.GetEvents()[0]); NUnit.Framework.Assert.IsTrue(eventCounter.GetMetaInfos()[0] is TestMetaInfo); } finally { EventCounterHandler.GetInstance().Unregister(factory); tesseractReader.SetThreadLocalMetaInfo(null); } }