Exemplo n.º 1
0
 public virtual void Expect(Expression<Func<bool>> expression)
 {
     if (EnableExpressionInspection)
     {
         var inspector = new InspectExpressionVisitor();
         inspector.Check(expression);
     }
     var pass = expression.Compile().Invoke();
     var visitor = new AssertionExpressionVisitor();
     visitor.GenerateAssertionMessage(expression);
     if (pass)
     {
         Console.Write("Assertion passed: ");
         Console.WriteLine(visitor.GetAssertionMessage());
         return;
     }
     throw new AssertionException(string.Format("Assertion failed: {0}", visitor.GetAssertionMessage()));
 }
 private string GetMessage(AssertionExpressionVisitor visitor)
 {
     var message = visitor.GetAssertionMessage();
     Console.WriteLine(message);
     return message;
 }