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.Inherited Members
Namespace: Akka.TestKit
Assembly: Akka.TestKit.dll
Syntax
public class TestLatch
Constructors
| Improve this Doc View SourceTestLatch()
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.
Declaration
public TestLatch()
TestLatch(Func<TimeSpan, TimeSpan>, TimeSpan, Int32)
TBD
Declaration
protected TestLatch(Func<TimeSpan, TimeSpan> dilate, TimeSpan defaultTimeout, int count)
Parameters
Type | Name | Description |
---|---|---|
Func<TimeSpan, TimeSpan> | dilate | TBD |
TimeSpan | defaultTimeout | TBD |
Int32 | count | TBD |
TestLatch(Int32)
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.
Declaration
public TestLatch(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | TBD |
TestLatch(Int32, 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.
Declaration
public TestLatch(int count, TimeSpan defaultTimeout)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | TBD |
TimeSpan | defaultTimeout | TBD |
Fields
| Improve this Doc View SourceDefaultTimeout
Obsolete. This field will be removed. DefaultTimeout is an alternative.
Declaration
[Obsolete("This field will be removed. TestKitSettings.DefaultTimeout is an alternative.")]
public static readonly TimeSpan DefaultTimeout
Field Value
Type | Description |
---|---|
TimeSpan |
Properties
| Improve this Doc View SourceIsOpen
Gets a value indicating whether the latch is open.
Declaration
public bool IsOpen { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceCountDown()
Count down the latch.
Declaration
public void CountDown()
Open()
Make this instance become open.
Declaration
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
Declaration
public void Ready()
Exceptions
Type | Condition |
---|---|
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
Declaration
public void Ready(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | TBD |
Exceptions
Type | Condition |
---|---|
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.
Declaration
public void Reset()