コード例 #1
0
        /// <summary>
        /// Executes the code and returns success if an exception is thrown.
        /// </summary>
        /// <param name="actual">A delegate representing the code to be tested</param>
        /// <returns>True if an exception is thrown, otherwise false</returns>
        protected override ConstraintResult ApplyConstraint <T>(T actual)
        {
            var exception = ExceptionInterceptor.Intercept(actual);

            return(new ThrowsExceptionConstraintResult(this, exception));
        }
コード例 #2
0
        /// <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>
        protected override ConstraintResult ApplyConstraint <T>(T actual)
        {
            _caughtException = ExceptionInterceptor.Intercept(actual);

            return(new ConstraintResult(this, _caughtException, _caughtException == null));
        }