/// <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()); } }
/// <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()); } }
/// <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()); } }
/// <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()); } }
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()); } }
public override bool Matches(object actual) { return(!constraint.Matches(actual)); }