BuildException() public static méthode

Builds an exception with the given message. Automatically detect the exception type to use depending on the used check framework.
public static BuildException ( string theMessage ) : Exception
theMessage string The message to build the exception with.
Résultat System.Exception
Exemple #1
0
 /// <summary>
 ///     Verify that the code results in a failed NFluent check with a specified message.
 /// </summary>
 /// <param name="check"></param>
 /// <returns>A link check</returns>
 public static ICheckLink <ICodeCheck <RunTrace> > IsAFaillingCheck(this ICodeCheck <RunTrace> check)
 {
     ExtensibilityHelper.BeginCheck(check)
     .SetSutName("fluent check")
     .CheckSutAttributes((sut) => sut.RaisedException, "raised exception")
     .FailIfNull("The fluent check did not raise an exception, where as it must.")
     .FailWhen((sut) => !ExceptionHelper.IsFailedException(sut),
               "The exception raised is not of the expected type").
     DefineExpectedType(ExceptionHelper.BuildException(string.Empty).GetType()).
     EndCheck();
     return(ExtensibilityHelper.BuildCheckLink(check));
 }
Exemple #2
0
 /// <summary>
 ///     Verify that the code results in a failed NFluent check with a specified message.
 /// </summary>
 /// <param name="check"></param>
 /// <returns>A link check</returns>
 public static ICheckLink <ICodeCheck <RunTrace> > IsAFaillingCheck(this ICodeCheck <RunTrace> check)
 {
     ExtensibilityHelper.BeginCheck(check)
     .GetSutProperty((sut) => sut.RaisedException, "raised exception")
     .SutNameIs("fluent check")
     .FailsIfNull()
     .FailsIf((sut) => !ExceptionHelper.IsFailedException(sut),
              "The exception raised is not of the expected type").
     ExpectingType(ExceptionHelper.BuildException(string.Empty).GetType(), "an instance of:", "an instance of a different type").
     EndCheck();
     return(ExtensibilityHelper.BuildCheckLink(check));
 }