public static void IsTrue(Expression <Func <bool> > expression) { Func <bool> func = expression.Compile(); if (!func()) { throw PAssertFormatter.CreateException(expression, "Assertion failed"); } }
internal static void ScenarioFailedIfAny(this IEnumerable <LambdaExpression> failed) { failed = failed.ToList(); if (failed.Any()) { throw new ScenarioException("The following assertions failed:" + Environment.NewLine + failed.Aggregate( new StringBuilder(), (builder, assertion) => builder.Append('\t').Append(PAssertFormatter.CreateSimpleFormatFor(assertion)).AppendLine())); } }
private static IEnumerable <string> NicePrintExpression(LambdaExpression target, string prefix) { yield return(prefix + PAssertFormatter.CreateSimpleFormatFor(target)); }