Exemple #1
0
        private static object InvokeDelegate <T>(ActualValueDelegate <T> del)
        {
#if ASYNC
            var    invokeResult = del.Invoke();
            object awaitedResult;
            return(AwaitUtils.TryAwait(del, invokeResult, out awaitedResult) ? awaitedResult : invokeResult);
#else
            return(del.Invoke());
#endif
        }
Exemple #2
0
        /// <summary>
        /// Applies the constraint to an ActualValueDelegate that returns
        /// the value to be tested. The default implementation simply evaluates
        /// the delegate but derived classes may override it to provide for
        /// delayed processing.
        /// </summary>
        /// <param name="del">An ActualValueDelegate</param>
        /// <returns>A ConstraintResult</returns>
        public virtual ConstraintResult ApplyTo <TActual>(ActualValueDelegate <TActual> del)
        {
#if ASYNC
            var    invokeResult = GetTestObject(del);
            object awaitedResult;
            return(ApplyTo(AwaitUtils.TryAwait(del, invokeResult, out awaitedResult) ? awaitedResult : invokeResult));
#else
            return(ApplyTo(GetTestObject(del)));
#endif
        }
Exemple #3
0
        private void RunAsyncOrNonAsyncMethod(MethodInfo method, TestExecutionContext context)
        {
            object _;

            AwaitUtils.TryAwait(method, RunNonAsyncMethod(method, context), out _);
        }