MockVerifyWithTimeout Method

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

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

public void VerifyWithTimeout()
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 This is automatically called when using MockManager.VerifyWithTimeout() see VerifyWithTimeout
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 for the mocked methods to be called, or the timeout.
    // Default timeout is 5000 milliseconds
    productMock.VerifyWithTimeout();        
}
See Also

Reference