MockManagerVerifyWithTimeout Method (Int32)

Typemock Isolator Developer Guide
Wait with timeout (im milliseconds) for all expected methods to be called

Namespace:  TypeMock
Assembly:  TypeMock (in TypeMock.dll) Version: 9.4.1.0 (9.4.1.0)
Syntax

public static void VerifyWithTimeout(
	int millisecondsTimeout
)

Parameters

millisecondsTimeout
Type: SystemInt32
Time to wait for all expected methods to be called
Remarks

VerifyWithTimeout will wait for all expectations to be called. If the Timeout is triggered the test will fail. Part of Test Driver Development and Mock Methodology is being sure that ALL our expected calls where actually called. There are cases when mocks are called in a-synchronic code or are encapsulated in a try catch block and errors are not thrown to testing method. In these cases using VerifyWithTimeout will enable us to validate our code and return as soon as the expected methods are called without needing to add Pause statements
Examples

[Test]
public void TestCallsInOtherThread ()
{
    // Let mock the product -  it will not mock constructors;
    Mock productMock = MockManager.Mock(typeof(Product),Constructor.NotMocked);
    // CalculatePrice will return 10 - expect 10 as argument
    productMock.ExpectAndReturn("CalculatePrice",10F).Args(10);
    // our method will be called in a new thread
    Thread theThread = new Thread(new ThreadStart(RunWithWait));
    theThread.Start();
    // If we use Verify we dont know when the thread will actually be called
    // Here we WAIT 1000 milliseconds for the mocked methods to be called, or the timeout.
    MockManager.VerifyWithTimeout(1000);        
}
See Also

Reference