Ejemplo n.º 1
0
 /// <summary>
 /// Verifies that the actual value matches the expected one
 /// </summary>
 /// <param name="expected">The expected value</param>
 /// <param name="getActual">A delegate to a method that returns the actual value</param>
 /// <param name="validationMessage">The message that describes the validation, to be written in the log and to be reported in case of a failure</param>
 /// <param name="args">Additional format arguments to <paramref name="validationMessage"/></param>
 /// <typeparam name="T">The type of the value to compare</typeparam>
 /// <remarks>
 /// This method calls the method delegated by <paramref name="getActual"/> inside a try/catch clause, so that if either the comparison
 /// failed or the <paramref name="getActual"/> method failed, the program continues (mainly to reach the next assertions). The
 /// assertion's result is written to the log (whether it succeeded or failed), and only after <see cref="Dispose"/> is called, an
 /// <see cref="AssertFailedException"/> exception will be thrown.
 /// </remarks>
 public void AreEqual <T>(T expected, Func <T> getActual, string validationMessage, params object[] args)
 {
     Try(() =>
     {
         LoggerAssert.AreEqual(expected, getActual(), validationMessage, args);
     });
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Verifies the the specified condition is true
 /// </summary>
 /// <param name="condition">A delegate to a method that evaluates the condition</param>
 /// <param name="validationMessage">The message that describes the validation, to be written in the log and to be reported in case of a failure</param>
 /// <param name="args">Additional format arguments to <paramref name="validationMessage"/></param>
 /// <remarks>
 /// This method calls the method delegated by <paramref name="condition"/> inside a try/catch clause, so that if either it returns
 /// false or if fails, the program continues (mainly to reach the next assertions). The assertion's result is written to the log
 /// (whether it succeeded or failed), and only after <see cref="Dispose"/> is called, an <see cref="AssertFailedException"/> exception
 /// will be thrown.
 /// </remarks>
 public void IsTrue(Func <bool> condition, string validationMessage, params object[] args)
 {
     Try(() =>
     {
         LoggerAssert.IsTrue(condition(), validationMessage, args);
     });
 }