public void NeverAssertionFailed( [CanBeNull] string description, [CanBeNull] TransformExceptionDelegate transformException, [CanBeNull] Assembly callerAssembly, [CanBeNull] string callerFilePath, [CanBeNull] int?callerLineNumber, [CanBeNull] string callerMemberName) { Exception[] _resolveDataErrorExceptions; var _data = _TryResolveData(_GetDataResolvers, out _resolveDataErrorExceptions); var _record = AssertionRecordHelper.CreateRecord( _data, description, callerAssembly, callerFilePath, callerLineNumber, callerMemberName); Exception _reportErrorException; _ReportFailure(MustAssertionType.AssertNever, _record, out _reportErrorException); throw AssertionExceptionHelper.CreateAssertionException( transformException: transformException, assertionRecord: _record, additionalExceptions: ExceptionHelper.Combine(_resolveDataErrorExceptions, ExceptionHelper.Yield(_reportErrorException))); }
public static bool RegisterConstructor <TException>([NotNull] TransformExceptionDelegate constructor) { if (constructor == null) { throw new ArgumentNullException(nameof(constructor)); } return(_ExceptionConstructors.TryAdd(typeof(TException), constructor)); }
public static bool RegisterConstructor([NotNull] Type exceptionType, [NotNull] TransformExceptionDelegate constructor) { if (exceptionType == null) { throw new ArgumentNullException(nameof(exceptionType)); } if (constructor == null) { throw new ArgumentNullException(nameof(constructor)); } return(_ExceptionConstructors.TryAdd(exceptionType, constructor)); }
public static MustAssertionException AssertNever( this IMustAssertable must, TransformExceptionDelegate transformException = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0, [CallerMemberName] string callerMemberName = null) { must.Api.NeverAssertionFailed( description: null, transformException: transformException, callerAssembly: null, callerFilePath: callerFilePath, callerLineNumber: callerLineNumber, callerMemberName: callerMemberName); // This cannot happen return(null); }
public static IMustAssertable Assert( this IMustAssertable must, bool assertionPassed, TransformExceptionDelegate transformException = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0, [CallerMemberName] string callerMemberName = null) { if (!assertionPassed) { must.Api.AssertionFailed( description: null, transformException: transformException, callerAssembly: null, callerFilePath: callerFilePath, callerLineNumber: callerLineNumber, callerMemberName: callerMemberName); } return(must); }
public static Exception CreateAssertionException( [CanBeNull][InstantHandle] TransformExceptionDelegate transformException, [CanBeNull] MustAssertionRecord assertionRecord, [CanBeNull] params Exception[] additionalExceptions) { var _assertionException = new MustAssertionException(assertionRecord); Exception _transformedException; Exception _transformExceptionErrorException; if (transformException == null) { _transformedException = _assertionException; _transformExceptionErrorException = null; } else { try { _transformedException = transformException(_assertionException) ?? _assertionException; _transformExceptionErrorException = null; } catch (Exception _exception) { _transformedException = _assertionException; _transformExceptionErrorException = _exception; } } var _finalException = ExceptionHelper.Combine( ExceptionHelper.Yield(_transformedException), ExceptionHelper.Yield(_transformExceptionErrorException), additionalExceptions); return(_finalException); }