Evaluates repeatedly the specified condition until it becomes fulfilled, or throws a AssertionFailureException if a timeout occured, or if the evaluation was done unsuccessfully too many times.

Namespace:  MbUnit.Framework
Assembly:  MbUnit (in MbUnit.dll) Version: 3.2.0.0 (3.2.528.0)

Syntax

C#
public sealed class Retry
Visual Basic (Declaration)
Public NotInheritable Class Retry

Examples

Here is an example that illustrates the usage of Retry.
CopyC#
[TestFixture]
public class FooTest
{
    [Test]
    public void MyRetryTest()
    {
        Retry.Repeat(10) // Retries maximum 10 times the evaluation of the condition.
             .WithPolling(TimeSpan.FromSeconds(1)) // Waits approximatively for 1 second between each evaluation of the condition.
             .WithTimeout(TimeSpan.FromSeconds(30)) // Sets a timeout of 30 seconds.
             .DoBetween(() => { /* DoSomethingBetweenEachCall */ })
             .Until(() => { return EvaluateSomeCondition(); });
    }
}

Inheritance Hierarchy

System..::.Object
  MbUnit.Framework..::.Retry

See Also