Esempio n. 1
0
 /// <summary>
 /// Apply a constraint to an actual value, succeedingt if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="constraint">A Constraint to be applied</param>
 /// <param name="actual">The actual value to test</param>
 /// <param name="message">The message that will be displayed on failure</param>
 /// <param name="args">Arguments to be used in formatting the message</param>
 static public void That(object actual, Constraint constraint, string message, params object[] args)
 {
     Assert.IncrementAssertCount();
     if (!constraint.Matches(actual))
     {
         MessageWriter writer = new TextMessageWriter(message, args);
         constraint.WriteMessageTo(writer);
         throw new AssertionException(writer.ToString());
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Apply a constraint to an actual value, succeeding if the constraint
        /// is satisfied and throwing an InconclusiveException on failure.
        /// </summary>
        /// <param name="expression">A Constraint expression to be applied</param>
        /// <param name="actual">The actual value to test</param>
        /// <param name="message">The message that will be displayed on failure</param>
        /// <param name="args">Arguments to be used in formatting the message</param>
        static public void That(object actual, IResolveConstraint expression, string message, params object[] args)
        {
            Constraint constraint = expression.Resolve();

            if (!constraint.Matches(actual))
            {
                MessageWriter writer = new TextMessageWriter(message, args);
                constraint.WriteMessageTo(writer);
                throw new InconclusiveException(writer.ToString());
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Apply a constraint to an actual value, succeeding if the constraint
        /// is satisfied and throwing an InconclusiveException on failure.
        /// </summary>
        /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
        /// <param name="expr">A Constraint expression to be applied</param>
        /// <param name="message">The message that will be displayed on failure</param>
        /// <param name="args">Arguments to be used in formatting the message</param>
        static public void That <T>(ActualValueDelegate <T> del, IResolveConstraint expr, string message, params object[] args)
        {
            Constraint constraint = expr.Resolve();

            if (!constraint.Matches(del))
            {
                MessageWriter writer = new TextMessageWriter(message, args);
                constraint.WriteMessageTo(writer);
                throw new InconclusiveException(writer.ToString());
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Apply a constraint to a referenced value, succeeding if the constraint
        /// is satisfied and throwing an assertion exception on failure.
        /// </summary>
        /// <param name="constraint">A Constraint to be applied</param>
        /// <param name="actual">The actual value to test</param>
        /// <param name="message">The message that will be displayed on failure</param>
        /// <param name="args">Arguments to be used in formatting the message</param>
        static public void That(ref bool actual, IResolveConstraint expression, string message, params object[] args)
        {
            Constraint constraint = expression.Resolve();

            Assert.IncrementAssertCount();
            if (!constraint.Matches(ref actual))
            {
                MessageWriter writer = new TextMessageWriter(message, args);
                constraint.WriteMessageTo(writer);
                throw new AssertionException(writer.ToString());
            }
        }
Esempio n. 5
0
        public static void That <T>(ref T actual, IResolveConstraint expression, string message, params object[] args)
        {
            Constraint constraint = expression.Resolve();

            TestExecutionContext.CurrentContext.IncrementAssertCount();
            if (!constraint.Matches(ref actual))
            {
                MessageWriter messageWriter = new TextMessageWriter(message, args);
                constraint.WriteMessageTo(messageWriter);
                throw new AssertionException(messageWriter.ToString());
            }
        }
Esempio n. 6
0
 public override bool Matches(object actual)
 {
     return(!constraint.Matches(actual));
 }
Esempio n. 7
0
 /// <summary>
 /// Apply a constraint to an actual value, succeedingt if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="constraint">A Constraint to be applied</param>
 /// <param name="actual">The actual value to test</param>
 /// <param name="message">The message that will be displayed on failure</param>
 /// <param name="args">Arguments to be used in formatting the message</param>
 static public void That(object actual, Constraint constraint, string message, params object[] args)
 {
     Assert.IncrementAssertCount();
     if (!constraint.Matches(actual))
     {
         MessageWriter writer = new TextMessageWriter(message, args);
         constraint.WriteMessageTo(writer);
         throw new AssertionException(writer.ToString());
     }
 }