Exemple #1
0
        /// <summary>
        ///     Executes the code of the delegate and captures any exception.
        ///     If a non-null base constraint was provided, it applies that
        ///     constraint to the exception.
        /// </summary>
        /// <param name="actual">A delegate representing the code to be tested</param>
        /// <returns>True if an exception is thrown and the constraint succeeds, otherwise false</returns>
        public override bool Matches(object actual)
        {
            caughtException = ExceptionInterceptor.Intercept(actual);

            if (caughtException == null)
            {
                return(false);
            }

            return(baseConstraint == null || baseConstraint.Matches(caughtException));
        }
        /// <summary>
        ///     Test whether the constraint is satisfied by a given value
        /// </summary>
        /// <param name="actual">The value to be tested</param>
        /// <returns>True if no exception is thrown, otherwise false</returns>
        public override bool Matches(object actual)
        {
            caughtException = ExceptionInterceptor.Intercept(actual);

            return(caughtException == null);
        }