public RuntimeEnvironment(string extension, ISynchronizeInvoke synchronizingObject, TimeSpan workFolderStateMinimumIdle)
        {
            AxCryptExtension = extension;

            _workFolderWatcher = CreateFileWatcher(WorkFolder.FullName);
            _workFolderWatcher.FileChanged += HandleWorkFolderFileChangedEvent;

            _delayedWorkFolderStateChanged = new DelayedAction(OnWorkFolderStateChanged, workFolderStateMinimumIdle, synchronizingObject);
        }
Esempio n. 2
0
 public static void TestShortDelayButNoStart()
 {
     bool wasHere = false;
     using (DelayedAction delayedAction = new DelayedAction(() => { wasHere = true; }, new TimeSpan(0, 0, 0, 0, 1), null))
     {
         Thread.Sleep(50);
         Assert.That(wasHere, Is.False, "The event should not be triggered until started.");
     }
 }
Esempio n. 3
0
 public static void TestEventAfterDispose()
 {
     bool wasHere = false;
     using (DelayedAction delayedAction = new DelayedAction(() => { wasHere = true; }, new TimeSpan(0, 0, 0, 0, 1), null))
     {
         delayedAction.RestartIdleTimer();
         Assert.That(wasHere, Is.False, "The event should not be triggered immediately.");
     }
     Thread.Sleep(50);
     Assert.That(wasHere, Is.False, "The event should be note be triggered once disposed.");
 }
Esempio n. 4
0
 public static void TestShortDelayAndImmediateStart()
 {
     bool wasHere = false;
     using (DelayedAction delayedAction = new DelayedAction(() => { wasHere = true; }, new TimeSpan(0, 0, 0, 0, 1), null))
     {
         delayedAction.RestartIdleTimer();
         Thread.Sleep(50);
         Assert.That(wasHere, Is.True, "The event should be triggered once started.");
         wasHere = false;
         Thread.Sleep(50);
         Assert.That(wasHere, Is.False, "The event should not be triggered more than once.");
     }
 }
Esempio n. 5
0
 public static void TestManyRestartsButOnlyOneEvent()
 {
     int eventCount = 0;
     using (DelayedAction delayedAction = new DelayedAction(() => { ++eventCount; }, new TimeSpan(0, 0, 0, 0, 5), null))
     {
         for (int i = 0; i < 10; ++i)
         {
             delayedAction.RestartIdleTimer();
         }
         Thread.Sleep(50);
         Assert.That(eventCount, Is.EqualTo(1), "The event should be triggered exactly once.");
         Thread.Sleep(50);
         Assert.That(eventCount, Is.EqualTo(1), "The event should still be triggered exactly once.");
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (_workFolderWatcher != null)
     {
         _workFolderWatcher.Dispose();
         _workFolderWatcher = null;
     }
     if (_delayedWorkFolderStateChanged != null)
     {
         _delayedWorkFolderStateChanged.Dispose();
         _delayedWorkFolderStateChanged = null;
     }
 }
Esempio n. 7
0
 public static void TestObjectDisposedException()
 {
     DelayedAction delayedAction = new DelayedAction(() => { }, new TimeSpan(0, 0, 0, 0, 1), null);
     delayedAction.Dispose();
     Assert.Throws<ObjectDisposedException>(() => { delayedAction.RestartIdleTimer(); });
 }
Esempio n. 8
0
 public static void TestNullArgument()
 {
     Action nullAction = null;
     DelayedAction delayedAction;
     Assert.Throws<ArgumentNullException>(() => { delayedAction = new DelayedAction(nullAction, new TimeSpan(0, 0, 1), null); }, "The 'action' argument is not allowed to be null");
 }