/// <summary> /// Verify that <paramref name="mustBeTrue"/> really is true. /// </summary> public static void Require(bool mustBeTrue, string message) { InternalContract.RequireNotNullOrWhitespace(message, nameof(message)); var m = GetErrorMessageIfFalse(mustBeTrue, message); MaybeThrowException(m); }
/// <summary> /// Always fail, with the given <paramref name="message"/>. /// </summary> public static void Fail(string message) { InternalContract.RequireNotNullOrWhitespace(message, nameof(message)); ThrowException(message); }
private static string GetErrorMessageIfFalse(bool mustBeTrue, string message) { InternalContract.RequireNotNullOrWhitespace(message, nameof(message)); return(mustBeTrue ? null : message); }
/// <summary> /// Verify that <paramref name="mustBeTrue"/> is true. /// </summary> /// <param name="mustBeTrue">The value that must be true.</param> /// <param name="message">A message that documents/explains this failure. This message should normally start with "Expected ...".</param> /// <param name="errorLocation">A unique errorLocation for the part of errorLocation where the validation didn't hold.</param> public static void IsTrue(bool mustBeTrue, string errorLocation, string message) { InternalContract.RequireNotNull(errorLocation, nameof(errorLocation)); InternalContract.RequireNotNullOrWhitespace(message, nameof(message)); GenericAssert <FulcrumAssertionFailedException> .IsTrue(mustBeTrue, errorLocation, message); }