Exemplo n.º 1
0
        protected void WaitUntil(DoFunc<bool> waitWhile, BuildTimeOutExceptionMessage exceptionMessage)
        {
            if (_waitForCompleteTimer == null) throw new WatiNException("_waitForCompleteTimer not initialized");

            var timeOut = new TryFuncUntilTimeOut(_waitForCompleteTimer) {ExceptionMessage = exceptionMessage};
            timeOut.Try(waitWhile);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Waits until the method returns true or false.
        /// </summary>
        /// <param name="func">The function to evaluate.</param>
        /// <param name="exceptionMessage">A function to build an exception message.</param>
        /// <returns>The last function result.</returns>
        /// <exception cref="TimeoutException">Thrown if a timeout occurs.</exception>
        protected bool WaitUntilNotNull(DoFunc <bool?> func, BuildTimeOutExceptionMessage exceptionMessage)
        {
            var result = false;

            WaitUntil(() =>
            {
                var currentResult = func();
                if (currentResult.HasValue)
                {
                    result = currentResult.Value;
                    return(true);
                }
                return(false);
            }, exceptionMessage);
            return(result);
        }
Exemplo n.º 3
0
        protected virtual void WaitUntil(DoFunc<bool> waitWhile, BuildTimeOutExceptionMessage exceptionMessage)
        {
            if (Timer == null)
                throw new WatiNException("_waitForCompleteTimer not initialized");

            var timeOut = new TryFuncUntilTimeOut(Timer) {ExceptionMessage = exceptionMessage};
            timeOut.Try(waitWhile);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Waits until the method returns true or false.
 /// </summary>
 /// <param name="func">The function to evaluate.</param>
 /// <param name="exceptionMessage">A function to build an exception message.</param>
 /// <returns>The last function result.</returns>
 /// <exception cref="TimeoutException">Thrown if a timeout occurs.</exception>
 protected bool WaitUntilNotNull(DoFunc<bool?> func, BuildTimeOutExceptionMessage exceptionMessage)
 {
     var result = false;
     WaitUntil(() =>
         {
             var currentResult = func();
             if (currentResult.HasValue)
             {
                 result = currentResult.Value;
                 return true;
             }
             return false;
         }, exceptionMessage);
     return result;
 }