Esempio n. 1
0
        /// <summary>
        /// Executes a method that returns a value and returns the result of operation.
        /// </summary>
        /// <param name="method">A value-return delegate.</param>
        /// <param name="returnedValue">A value returned by the method.</param>
        /// <typeparam name="T">The type of the value returned by the method.</typeparam>
        /// <returns>The result of a method invocation.</returns>
        public static ExecutionResult Execute <T>(Func <T> method, out T returnedValue)
        {
            T value = default(T);
            ExecutionResult result = SafeExecutor.Execute(() => { value = method(); });

            returnedValue = value;
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// The verify action in 'safe' mode. If action performing leads to a new exception the assert will be registred as failed
        /// </summary>
        /// <param name="action">
        /// The action for verification
        /// </param>
        /// <param name="assertName">
        /// The assert name.
        /// </param>
        private void VerifyCondition(Action action, string assertName = null)
        {
            var conditonVerifyingResult = SafeExecutor.Execute(action);

            var assert = new Assert
            {
                Name      = string.IsNullOrEmpty(assertName) ? $"{action.Method.Name}" : assertName,
                Outcome   = conditonVerifyingResult.ResultType == ResultType.Success ? Outcome.Passed : Outcome.Failed,
                Exception = conditonVerifyingResult.Details
            };

            asserts.Add(assert);
        }