public void SimpleTimerThreeSeconds()
 {
     var timer = new SimpleTimer(TimeSpan.FromSeconds(3));
     Thread.Sleep(2500);
     Assert.IsFalse(timer.Elapsed);
     Thread.Sleep(1000);
     Assert.IsTrue(timer.Elapsed);
 }
        public IE TryFindIe(Constraint findBy, SimpleTimer timer)
        {
            var action = new TryFuncUntilTimeOut(timer)
            {
                SleepTime = TimeSpan.FromMilliseconds(500)
            };

            return action.Try(() => FindIEPartiallyInitialized(findBy));
        }
        public Browser FinishInitializationAndWaitForComplete(IE ie, SimpleTimer timer, bool waitForComplete)
        {
            ie.FinishInitialization(null);

            if (waitForComplete)
            {
                var ieWaitForComplete = new IEWaitForComplete((IEBrowser) ie.NativeBrowser) { Timer = timer };
                ie.WaitForComplete(ieWaitForComplete);
            }

            return ie;
        }
        public Browser Find(Constraint findBy, int timeout, bool waitForComplete)
        {
        	Logger.LogAction((LogFunction log) => { log("Busy finding Internet Explorer matching constraint {0}", findBy); });

            var timer = new SimpleTimer(TimeSpan.FromSeconds(timeout));

            var ie = TryFindIe(findBy, timer);
            
            if (ie != null)
            {
                return FinishInitializationAndWaitForComplete(ie, timer, waitForComplete);
            }

            throw new BrowserNotFoundException("IE", findBy.ToString(), timeout);
        }
 public void SimpleTimerOneSecond()
 {
     var timer = new SimpleTimer(TimeSpan.FromSeconds(1));
     Thread.Sleep(1200);
     Assert.IsTrue(timer.Elapsed);
 }
 public void SimpleTimerWithZeroTimoutIsAllowed()
 {
     var timer = new SimpleTimer(TimeSpan.FromSeconds(0));
     Assert.IsTrue(timer.Elapsed);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TryFuncUntilTimeOut"/> class.
 /// </summary>
 /// <param name="timer">The timer instance which will be used when executing <see cref="Try{T}(DoFunc{T})"/>.</param>
 public TryFuncUntilTimeOut(SimpleTimer timer) : this(0)
 {
     _timer = timer;
 }