示例#1
0
        public static MustAssertionException AssertNever <TException>(
            this IMustAssertable must,
            Func <TException, Exception> transformException = null,
            [CallerFilePath] string callerFilePath          = null,
            [CallerLineNumber] int callerLineNumber         = 0,
            [CallerMemberName] string callerMemberName      = null)
            where TException : Exception, new()
        {
            must.Api.NeverAssertionFailed(
                description: null,
                transformException: CustomExceptionHelper.CreateCustomExceptionConstructorWithTransform(transformException),
                callerAssembly: null,
                callerFilePath: callerFilePath,
                callerLineNumber: callerLineNumber,
                callerMemberName: callerMemberName);

            // This cannot happen
            return(null);
        }
        public static IMustAssertable Assert <TException>(
            this IMustAssertable must,
            bool assertionPassed,
            Func <TException, Exception> transformException = null,
            [CallerFilePath] string callerFilePath          = null,
            [CallerLineNumber] int callerLineNumber         = 0,
            [CallerMemberName] string callerMemberName      = null)
            where TException : Exception
        {
            if (!assertionPassed)
            {
                must.Api.AssertionFailed(
                    description: null,
                    transformException: CustomExceptionHelper.CreateCustomExceptionConstructorWithTransform(transformException),
                    callerAssembly: null,
                    callerFilePath: callerFilePath,
                    callerLineNumber: callerLineNumber,
                    callerMemberName: callerMemberName);
            }

            return(must);
        }