Class TestLatch
A count down latch that initially is closed. In order for it to become open CountDown() must be called. By default one call is enough, but this can be changed by specifying the count in the constructor.
By default a timeout of 5 seconds is used.
When created using TestKit.CreateTestLatch the default timeout from DefaultTimeout is used and all timeouts are dilated, i.e. multiplied by TestTimeFactor
Timeouts will always throw an exception.public class TestLatch
- Inheritance
-
TestLatch
- Inherited Members
Constructors
TestLatch()
Initializes a new instance of the TestLatch class with count = 1, i.e. the instance will become open after one call to CountDown(). The default timeout is set to 5 seconds.
public TestLatch()
TestLatch(Func<TimeSpan, TimeSpan>, TimeSpan, int)
TBD
protected TestLatch(Func<TimeSpan, TimeSpan> dilate, TimeSpan defaultTimeout, int count)
Parameters
TestLatch(int)
Initializes a new instance of the TestLatch class with the specified count, i.e number of times CountDown() must be called to make this instance become open. The default timeout is set to 5 seconds.
public TestLatch(int count)
Parameters
count
intTBD
TestLatch(int, TimeSpan)
Initializes a new instance of the TestLatch class with the specified count, i.e number of times CountDown() must be called to make this instance become open.
public TestLatch(int count, TimeSpan defaultTimeout)
Parameters
Fields
DefaultTimeout
Obsolete. This field will be removed. DefaultTimeout is an alternative.
[Obsolete("This field will be removed. TestKitSettings.DefaultTimeout is an alternative.")]
public static readonly TimeSpan DefaultTimeout
Field Value
Properties
IsOpen
Gets a value indicating whether the latch is open.
public bool IsOpen { get; }
Property Value
Methods
CountDown()
Count down the latch.
public void CountDown()
Open()
Make this instance become open.
public void Open()
Ready()
Expects the latch to become open within the default timeout. If the timeout is reached, a TimeoutException is thrown.
If no timeout was specified when creating this instance, 5 seconds is used.
If this instance has been created using TestKit.CreateTestLatch the default timeout from DefaultTimeout is used and dilated, i.e. multiplied by TestTimeFactor
public void Ready()
Exceptions
- TimeoutException
This exception is thrown when the timeout is reached.
Ready(TimeSpan)
Expects the latch to become open within the specified timeout. If the timeout is reached, a TimeoutException is thrown.
If this instance has been created using TestKit.CreateTestLatch
timeout
is dilated, i.e. multiplied by TestTimeFactor
public void Ready(TimeSpan timeout)
Parameters
timeout
TimeSpanTBD
Exceptions
- ArgumentException
This exception is thrown when a too large timeout has been specified.
- TimeoutException
This exception is thrown when the timeout is reached.
Reset()
Reset this instance to the initial count, making it become closed.
public void Reset()