For a problem like this, I would probably use Task
and Task.Wait(int)
or Task.Wait(TimeSpan)
. For example:
[Test]
public void BlockingCallShouldBlock()
{
var task = Task.Run(() => SomeBlockingCall());
var completedInTime = task.Wait(50); // Also an overload available for TimeSpan
Expect(completedInTime, Is.False);
}
Be warned however, this will invoke SomeBlockingCall
on a background thread, but for the majority of unit tests, this is a non-issue.