public virtual void DisableHooksTest()
        {
            int betweenChecksSleepTime = 500;
            int handlerSleepTime       = 100;

            DataHandlerCounterTest.TestDataHandler dataHandler = new DataHandlerCounterTest.TestDataHandler(handlerSleepTime
                                                                                                            );
            DataHandlerCounterTest.TestDataHandlerCounter counter = new DataHandlerCounterTest.TestDataHandlerCounter(
                dataHandler);
            // check the initial process count
            NUnit.Framework.Assert.AreEqual(0, dataHandler.GetProcessCount());
            long count = dataHandler.GetProcessCount();

            Thread.Sleep(betweenChecksSleepTime);
            // check that process count has been updated
            NUnit.Framework.Assert.AreNotEqual(count, dataHandler.GetProcessCount());
            counter.Close();
            // ensure that last process on disable would be finished
            Thread.Sleep(betweenChecksSleepTime);
            long totalCount = dataHandler.GetProcessCount();

            Thread.Sleep(betweenChecksSleepTime);
            // ensure that after disabling there are no new processes has been invoked
            NUnit.Framework.Assert.AreEqual(totalCount, dataHandler.GetProcessCount());
        }
 public virtual void MultipleRegisterHooksTest()
 {
     DataHandlerCounterTest.TestDataHandler        dataHandler = new DataHandlerCounterTest.TestDataHandler(200);
     DataHandlerCounterTest.TestDataHandlerCounter counter     = new DataHandlerCounterTest.TestDataHandlerCounter(
         dataHandler);
     DataHandlerCounterTest.TestDataHandlerCounter secondCounter = new DataHandlerCounterTest.TestDataHandlerCounter
                                                                       (dataHandler);
     NUnit.Framework.Assert.DoesNotThrow(() => counter.Close());
     NUnit.Framework.Assert.DoesNotThrow(() => secondCounter.Close());
 }
 public virtual void OnEventAfterDisableTest()
 {
     DataHandlerCounterTest.TestDataHandlerCounter counter = new DataHandlerCounterTest.TestDataHandlerCounter(
         new DataHandlerCounterTest.TestDataHandler(100));
     DataHandlerCounterTest.TestEvent testEvent = new DataHandlerCounterTest.TestEvent("test");
     NUnit.Framework.Assert.DoesNotThrow(() => counter.OnEvent(testEvent, null));
     counter.Close();
     NUnit.Framework.Assert.That(() => {
         counter.OnEvent(testEvent, null);
     }
                                 , NUnit.Framework.Throws.InstanceOf <InvalidOperationException>().With.Message.EqualTo(PdfException.DataHandlerCounterHasBeenDisabled))
     ;
 }
        public virtual void TimedProcessWithExceptionTest()
        {
            int betweenChecksSleepTime = 500;
            int handlerSleepTime       = 100;

            DataHandlerCounterTest.TestDataHandlerWithException dataHandler = new DataHandlerCounterTest.TestDataHandlerWithException
                                                                                  (handlerSleepTime);
            DataHandlerCounterTest.TestDataHandlerCounter counter = new DataHandlerCounterTest.TestDataHandlerCounter(
                dataHandler);
            // check the initial process count
            NUnit.Framework.Assert.AreEqual(0, dataHandler.GetProcessCount());
            Thread.Sleep(betweenChecksSleepTime);
            // check that process count has not been updated
            NUnit.Framework.Assert.AreEqual(0, dataHandler.GetProcessCount());
            NUnit.Framework.Assert.DoesNotThrow(() => counter.Close());
        }