Beispiel #1
0
        public static void IsTrue(Expression <Func <bool> > expression)
        {
            Func <bool> func = expression.Compile();

            if (!func())
            {
                throw PAssertFormatter.CreateException(expression, "Assertion failed");
            }
        }
Beispiel #2
0
        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()));
            }
        }
Beispiel #3
0
 private static IEnumerable <string> NicePrintExpression(LambdaExpression target, string prefix)
 {
     yield return(prefix + PAssertFormatter.CreateSimpleFormatFor(target));
 }