Class TestKitBase
Implements
Inherited Members
Namespace: Akka.TestKit
Assembly: Akka.TestKit.dll
Syntax
public abstract class TestKitBase : IActorRefFactory
Constructors
| Edit this page View SourceTestKitBase(ITestKitAssertions, ActorSystem, ActorSystemSetup, string, string)
Declaration
protected TestKitBase(ITestKitAssertions assertions, ActorSystem system, ActorSystemSetup config, string actorSystemName, string testActorName)
Parameters
| Type | Name | Description |
|---|---|---|
| ITestKitAssertions | assertions | |
| ActorSystem | system | |
| ActorSystemSetup | config | |
| string | actorSystemName | |
| string | testActorName |
TestKitBase(ITestKitAssertions, ActorSystem, string)
Create a new instance of the TestKitBase class.
If no system is passed in, a new system
with DefaultConfig will be created.
Declaration
protected TestKitBase(ITestKitAssertions assertions, ActorSystem system = null, string testActorName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ITestKitAssertions | assertions | The framework-specific assertion tools. |
| ActorSystem | system | Optional: The actor system. |
| string | testActorName | Optional: The name of the TestActor. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | This exception is thrown when the given |
TestKitBase(ITestKitAssertions, ActorSystemSetup, string, string)
Create a new instance of the TestKitBase class. A new system with the specified configuration will be created.
Declaration
protected TestKitBase(ITestKitAssertions assertions, ActorSystemSetup setup, string actorSystemName = null, string testActorName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ITestKitAssertions | assertions | The set of assertions used by the TestKit. |
| ActorSystemSetup | setup | The ActorSystemSetup to use for the configuring the system. |
| string | actorSystemName | Optional: the name of the ActorSystem. |
| string | testActorName | Optional: the name of the TestActor. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | This exception is thrown when the given |
TestKitBase(ITestKitAssertions, Config, string, string)
Create a new instance of the TestKitBase class. A new system with the specified configuration will be created.
Declaration
protected TestKitBase(ITestKitAssertions assertions, Config config, string actorSystemName = null, string testActorName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ITestKitAssertions | assertions | The set of assertions used by the TestKit. |
| Config | config | The configuration to use for the system. |
| string | actorSystemName | Optional: the name of the ActorSystem. |
| string | testActorName | Optional: the name of the TestActor. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | This exception is thrown when the given |
Properties
| Edit this page View SourceDefaultConfig
The default TestKit configuration.
Declaration
public static Config DefaultConfig { get; }
Property Value
| Type | Description |
|---|---|
| Config |
EventFilter
Filter LogEvent sent to the system's EventStream. In order to be able to filter the log the special logger TestEventListener must be installed using the config
akka.loggers = ["Akka.TestKit.TestEventListener, Akka.TestKit"]
It is installed by default in testkit.
Declaration
public EventFilterFactory EventFilter { get; }
Property Value
| Type | Description |
|---|---|
| EventFilterFactory |
FullDebugConfig
A full debugging configuration with all log settings enabled.
Declaration
public static Config FullDebugConfig { get; }
Property Value
| Type | Description |
|---|---|
| Config |
HasMessages
Returns true if messages are available.
Declaration
public bool HasMessages { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
LastMessage
The last message received by the TestActor.
Declaration
public object LastMessage { get; }
Property Value
| Type | Description |
|---|---|
| object |
LastSender
Declaration
public IActorRef LastSender { get; }
Property Value
| Type | Description |
|---|---|
| IActorRef |
Log
The built-in ILoggingAdapter used by Sys.
Declaration
public ILoggingAdapter Log { get; }
Property Value
| Type | Description |
|---|---|
| ILoggingAdapter |
Now
The current time.
Declaration
public static TimeSpan Now { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Remaining
Retrieves the time remaining for execution of the innermost enclosing Within block.
Declaration
public TimeSpan Remaining { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This exception is thrown when called from outside of |
RemainingOrDefault
Retrieves the time remaining for execution of the innermost enclosing Within block. If missing that, then it returns the properly dilated default for this case from settings (key: "akka.test.single-expect-default").
Declaration
public TimeSpan RemainingOrDefault { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Sys
The ActorSystem that is recreated and used for each test.
Declaration
public ActorSystem Sys { get; }
Property Value
| Type | Description |
|---|---|
| ActorSystem |
TestActor
The default TestActor. The actor can be controlled by sending it special control messages, see TestActor.SetIgnore, TestActor.Watch, TestActor.Unwatch. You can also install an AutoPilot to drive the actor, see SetAutoPilot(AutoPilot). All other messages are forwarded to the queue and can be retrieved with Receive and the ExpectMsg overloads.
Declaration
public IActorRef TestActor { get; }
Property Value
| Type | Description |
|---|---|
| IActorRef |
TestKitSettings
The settings for the testkit.
Declaration
public TestKitSettings TestKitSettings { get; }
Property Value
| Type | Description |
|---|---|
| TestKitSettings |
Methods
| Edit this page View SourceActorOf(Props)
Create a new actor as child of Sys.
Declaration
public IActorRef ActorOf(Props props)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | The props configuration object |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
ActorOf(Props, string)
Create a new actor as child of Sys.
Declaration
public IActorRef ActorOf(Props props, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | The props configuration object |
| string | name | The name of the actor. |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
ActorOf(Action<IActorDsl, IActorContext>, string)
Creates a new actor by defining the behavior inside the configure action.
ActorOf(c =>
{
c.Receive<string>((msg, ctx) => ctx.Sender.Tell("Hello " + msg));
});
Declaration
public IActorRef ActorOf(Action<IActorDsl, IActorContext> configure, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<IActorDsl, IActorContext> | configure | An action that configures the actor's behavior. |
| string | name | Optional: The name of the actor. |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
ActorOf(Action<IActorDsl>, string)
Creates a new actor by defining the behavior inside the configure action.
ActorOf(c =>
{
c.Receive<string>((msg, ctx) => ctx.Sender.Tell("Hello " + msg));
});
Declaration
public IActorRef ActorOf(Action<IActorDsl> configure, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<IActorDsl> | configure | An action that configures the actor's behavior. |
| string | name | Optional: The name of the actor. |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
ActorOfAsTestActorRef<TActor>(IActorRef, string)
Create a new actor as child of the specified supervisor and returns it as TestActorRef<TActor> to enable access to the underlying actor instance via UnderlyingActor.
Declaration
public TestActorRef<TActor> ActorOfAsTestActorRef<TActor>(IActorRef supervisor, string name = null) where TActor : ActorBase, new()
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | supervisor | The supervisor |
| string | name | Optional: The name. |
Returns
| Type | Description |
|---|---|
| TestActorRef<TActor> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. It must have a parameterless public constructor |
ActorOfAsTestActorRef<TActor>(Props, IActorRef, string)
Create a new actor as child of specified supervisor and returns it as TestActorRef<TActor> to enable access to the underlying actor instance via UnderlyingActor.
Declaration
public TestActorRef<TActor> ActorOfAsTestActorRef<TActor>(Props props, IActorRef supervisor, string name = null) where TActor : ActorBase
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | The Props object |
| IActorRef | supervisor | The supervisor |
| string | name | Optional: The name. |
Returns
| Type | Description |
|---|---|
| TestActorRef<TActor> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. It must have a parameterless public constructor |
ActorOfAsTestActorRef<TActor>(Props, string)
Create a new actor as child of Sys and returns it as TestActorRef<TActor> to enable access to the underlying actor instance via UnderlyingActor.
Declaration
public TestActorRef<TActor> ActorOfAsTestActorRef<TActor>(Props props, string name = null) where TActor : ActorBase
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | The Props object |
| string | name | Optional: The name. |
Returns
| Type | Description |
|---|---|
| TestActorRef<TActor> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. It must have a parameterless public constructor |
ActorOfAsTestActorRef<TActor>(Expression<Func<TActor>>, IActorRef, string)
Create a new actor as child of the specified supervisor and returns it as TestActorRef<TActor>
to enable access to the underlying actor instance via UnderlyingActor.
Uses an expression that calls the constructor of TActor.
ActorOf<MyActor>(()=>new MyActor("value", 4711), "test-actor")
Declaration
public TestActorRef<TActor> ActorOfAsTestActorRef<TActor>(Expression<Func<TActor>> factory, IActorRef supervisor, string name = null) where TActor : ActorBase
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<TActor>> | factory | An expression that calls the constructor of |
| IActorRef | supervisor | The supervisor |
| string | name | Optional: The name. |
Returns
| Type | Description |
|---|---|
| TestActorRef<TActor> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. |
ActorOfAsTestActorRef<TActor>(Expression<Func<TActor>>, string)
Create a new actor as child of Sys and returns it as TestActorRef<TActor>
to enable access to the underlying actor instance via UnderlyingActor.
Uses an expression that calls the constructor of TActor.
ActorOf<MyActor>(()=>new MyActor("value", 4711), "test-actor")
Declaration
public TestActorRef<TActor> ActorOfAsTestActorRef<TActor>(Expression<Func<TActor>> factory, string name = null) where TActor : ActorBase
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<TActor>> | factory | An expression that calls the constructor of |
| string | name | Optional: The name. |
Returns
| Type | Description |
|---|---|
| TestActorRef<TActor> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. |
ActorOfAsTestActorRef<TActor>(string)
Create a new actor as child of Sys and returns it as TestActorRef<TActor> to enable access to the underlying actor instance via UnderlyingActor.
Declaration
public TestActorRef<TActor> ActorOfAsTestActorRef<TActor>(string name = null) where TActor : ActorBase, new()
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Optional: The name. |
Returns
| Type | Description |
|---|---|
| TestActorRef<TActor> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. It must have a parameterless public constructor |
ActorOfAsTestFSMRef<TFsmActor, TState, TData>(IActorRef, string, bool)
Create a new FSM<TState, TData> as child of the specified supervisor
and returns it as TestFSMRef<TActor, TState, TData> to enable inspecting and modifying the FSM directly.
TFsmActor must have a public parameterless constructor.
Declaration
public TestFSMRef<TFsmActor, TState, TData> ActorOfAsTestFSMRef<TFsmActor, TState, TData>(IActorRef supervisor, string name = null, bool withLogging = false) where TFsmActor : FSM<TState, TData>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | supervisor | The supervisor |
| string | name | Optional: The name. |
| bool | withLogging | Optional: If set to |
Returns
| Type | Description |
|---|---|
| TestFSMRef<TFsmActor, TState, TData> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TFsmActor | The type of the actor. It must have a parameterless public constructor |
| TState | The type of state name |
| TData | The type of state data |
ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Props, IActorRef, string, bool)
Create a new FSM<TState, TData> as child of the specified supervisor and returns it as TestFSMRef<TActor, TState, TData> to enable inspecting and modifying the FSM directly.
Declaration
public TestFSMRef<TFsmActor, TState, TData> ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Props props, IActorRef supervisor, string name = null, bool withLogging = false) where TFsmActor : FSM<TState, TData>
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | The Props object |
| IActorRef | supervisor | The supervisor |
| string | name | Optional: The name. |
| bool | withLogging | Optional: If set to |
Returns
| Type | Description |
|---|---|
| TestFSMRef<TFsmActor, TState, TData> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TFsmActor | The type of the actor. It must be a FSM<TState, TData> |
| TState | The type of state name |
| TData | The type of state data |
ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Props, string, bool)
Create a new FSM<TState, TData> as child of Sys and returns it as TestFSMRef<TActor, TState, TData> to enable inspecting and modifying the FSM directly.
Declaration
public TestFSMRef<TFsmActor, TState, TData> ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Props props, string name = null, bool withLogging = false) where TFsmActor : FSM<TState, TData>
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | The Props object |
| string | name | Optional: The name. |
| bool | withLogging | Optional: If set to |
Returns
| Type | Description |
|---|---|
| TestFSMRef<TFsmActor, TState, TData> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TFsmActor | The type of the actor. It must be a FSM<TState, TData> and have a public parameterless constructor |
| TState | The type of state name |
| TData | The type of state data |
ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Expression<Func<TFsmActor>>, IActorRef, string, bool)
Create a new FSM<TState, TData> as child of the specified supervisor
and returns it as TestFSMRef<TActor, TState, TData> to enable inspecting and modifying the FSM directly.
Uses an expression that calls the constructor of TFsmActor.
Declaration
public TestFSMRef<TFsmActor, TState, TData> ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Expression<Func<TFsmActor>> factory, IActorRef supervisor, string name = null, bool withLogging = false) where TFsmActor : FSM<TState, TData>
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<TFsmActor>> | factory | An expression that calls the constructor of |
| IActorRef | supervisor | The supervisor |
| string | name | Optional: The name. |
| bool | withLogging | Optional: If set to |
Returns
| Type | Description |
|---|---|
| TestFSMRef<TFsmActor, TState, TData> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TFsmActor | The type of the actor. |
| TState | The type of state name |
| TData | The type of state data |
ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Expression<Func<TFsmActor>>, string, bool)
Create a new FSM<TState, TData> as child of Sys
and returns it as TestFSMRef<TActor, TState, TData> to enable inspecting and modifying the FSM directly.
Uses an expression that calls the constructor of TFsmActor.
Declaration
public TestFSMRef<TFsmActor, TState, TData> ActorOfAsTestFSMRef<TFsmActor, TState, TData>(Expression<Func<TFsmActor>> factory, string name = null, bool withLogging = false) where TFsmActor : FSM<TState, TData>
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<TFsmActor>> | factory | An expression that calls the constructor of |
| string | name | Optional: The name. |
| bool | withLogging | Optional: If set to |
Returns
| Type | Description |
|---|---|
| TestFSMRef<TFsmActor, TState, TData> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TFsmActor | The type of the actor. |
| TState | The type of state name |
| TData | The type of state data |
ActorOfAsTestFSMRef<TFsmActor, TState, TData>(string, bool)
Create a new FSM<TState, TData> as child of Sys
and returns it as TestFSMRef<TActor, TState, TData> to enable inspecting and modifying the FSM directly.
TFsmActor must have a public parameterless constructor.
Declaration
public TestFSMRef<TFsmActor, TState, TData> ActorOfAsTestFSMRef<TFsmActor, TState, TData>(string name = null, bool withLogging = false) where TFsmActor : FSM<TState, TData>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Optional: The name. |
| bool | withLogging | Optional: If set to |
Returns
| Type | Description |
|---|---|
| TestFSMRef<TFsmActor, TState, TData> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TFsmActor | The type of the actor. It must have a parameterless public constructor |
| TState | The type of state name |
| TData | The type of state data |
ActorOf<TActor>()
Create a new actor as child of Sys.
Declaration
public IActorRef ActorOf<TActor>() where TActor : ActorBase, new()
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. It must have a parameterless public constructor |
ActorOf<TActor>(Expression<Func<TActor>>)
Create a new actor as child of Sys using an expression that calls the constructor
of TActor.
ActorOf<MyActor>(()=>new MyActor("value", 4711))
Declaration
public IActorRef ActorOf<TActor>(Expression<Func<TActor>> factory) where TActor : ActorBase
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<TActor>> | factory | An expression that calls the constructor of |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. |
ActorOf<TActor>(Expression<Func<TActor>>, string)
Create a new actor as child of Sys using an expression that calls the constructor
of TActor.
ActorOf<MyActor>(()=>new MyActor("value", 4711), "test-actor")
Declaration
public IActorRef ActorOf<TActor>(Expression<Func<TActor>> factory, string name) where TActor : ActorBase
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<TActor>> | factory | An expression that calls the constructor of |
| string | name | The name of the actor. |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. |
ActorOf<TActor>(string)
Create a new actor as child of Sys.
Declaration
public IActorRef ActorOf<TActor>(string name) where TActor : ActorBase, new()
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the actor. |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
Type Parameters
| Name | Description |
|---|---|
| TActor | The type of the actor. It must have a parameterless public constructor |
ActorSelection(ActorPath)
Creates an ActorSelection(ActorPath)
Declaration
public ActorSelection ActorSelection(ActorPath actorPath)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorPath | actorPath | The path of the actor(s) we want to select. |
Returns
| Type | Description |
|---|---|
| ActorSelection | An ActorSelection |
ActorSelection(IActorRef, string)
Creates an ActorSelection(string)
Declaration
public ActorSelection ActorSelection(IActorRef anchorRef, string actorPath)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | anchorRef | The base actor that anchors the |
| string | actorPath | The path of the actor(s) we want to select. |
Returns
| Type | Description |
|---|---|
| ActorSelection | An ActorSelection |
ActorSelection(string)
Creates an ActorSelection(string)
Declaration
public ActorSelection ActorSelection(string actorPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actorPath | The path of the actor(s) we want to select. |
Returns
| Type | Description |
|---|---|
| ActorSelection | An ActorSelection |
AwaitAssert(Action, TimeSpan?, TimeSpan?, CancellationToken)
Await until the given assertion does not throw an exception or the timeout expires, whichever comes first. If the timeout expires the last exception is thrown.
The action is called, and if it throws an exception the thread sleeps the specified interval before retrying.
If no timeout is given, take it from the innermost enclosing `within` block.
Note that the timeout is scaled using Dilated(TimeSpan), which uses the configuration entry "akka.test.timefactor".
Declaration
public void AwaitAssert(Action assertion, TimeSpan? duration = null, TimeSpan? interval = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | assertion | The action. |
| TimeSpan? | duration | The timeout. |
| TimeSpan? | interval | The interval to wait between executing the assertion. |
| CancellationToken | cancellationToken |
AwaitAssertAsync(Action, TimeSpan?, TimeSpan?, CancellationToken)
Await until the given assertion does not throw an exception or the timeout expires, whichever comes first. If the timeout expires the last exception is thrown.
The action is called, and if it throws an exception the thread sleeps the specified interval before retrying.
If no timeout is given, take it from the innermost enclosing `within` block.
Note that the timeout is scaled using Dilated(TimeSpan), which uses the configuration entry "akka.test.timefactor".
Declaration
public Task AwaitAssertAsync(Action assertion, TimeSpan? duration = null, TimeSpan? interval = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | assertion | The action. |
| TimeSpan? | duration | The timeout. |
| TimeSpan? | interval | The interval to wait between executing the assertion. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitAssertAsync(Func<Task>, TimeSpan?, TimeSpan?, CancellationToken)
Await until the given assertion does not throw an exception or the timeout expires, whichever comes first. If the timeout expires the last exception is thrown.
The action is called, and if it throws an exception the thread sleeps the specified interval before retrying.
If no timeout is given, take it from the innermost enclosing `within` block.
Note that the timeout is scaled using Dilated(TimeSpan), which uses the configuration entry "akka.test.timefactor".
Declaration
public Task AwaitAssertAsync(Func<Task> assertion, TimeSpan? duration = null, TimeSpan? interval = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task> | assertion | The action. |
| TimeSpan? | duration | The timeout. |
| TimeSpan? | interval | The interval to wait between executing the assertion. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitCondition(Func<bool>, TimeSpan?, TimeSpan?, string, CancellationToken)
Await until the given condition evaluates to true or the timeout
expires, whichever comes first.
If no timeout is given, take it from the innermost enclosing `within` block.
Note that the timeout is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor".
The parameter interval specifies the time between calls to conditionIsFulfilled
Between calls the thread sleeps. If interval is undefined the thread only sleeps
one time, using the max as duration, and then rechecks the condition and ultimately
succeeds or fails.
To make sure that tests run as fast as possible, make sure you do not leave this value as undefined, instead set it to a relatively small value.
Declaration
public void AwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan? max, TimeSpan? interval, string message = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
| TimeSpan? | max | The maximum duration. If undefined, uses the remaining time
(if inside a |
| TimeSpan? | interval | The time between calls to To make sure that tests run as fast as possible, make sure you do not set this value as undefined, instead set it to a relatively small value. |
| string | message | The message used if the timeout expires. |
| CancellationToken | cancellationToken |
AwaitCondition(Func<bool>, TimeSpan?, string, CancellationToken)
Await until the given condition evaluates to true or the timeout
expires, whichever comes first.
If no timeout is given, take it from the innermost enclosing `within` block (if inside a `within` block) or the value specified in config value "akka.test.single-expect-default". The value is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor"..
A call to conditionIsFulfilled is done immediately, then the threads sleep
for about a tenth of the timeout value, before it checks the condition again. This is repeated until
timeout or the condition evaluates to true. To specify another interval, use the overload
AwaitCondition(Func<bool>, TimeSpan?, TimeSpan?, string, CancellationToken)
Declaration
public void AwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan? max, string message, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
| TimeSpan? | max | The maximum duration. If undefined, uses the remaining time
(if inside a |
| string | message | The message used if the timeout expires. |
| CancellationToken | cancellationToken |
AwaitCondition(Func<bool>, TimeSpan?, CancellationToken)
Await until the given condition evaluates to true or the timeout
expires, whichever comes first.
If no timeout is given, take it from the innermost enclosing `within` block (if inside a `within` block) or the value specified in config value "akka.test.single-expect-default". The value is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor"..
A call to conditionIsFulfilled is done immediately, then the threads sleep
for about a tenth of the timeout value, before it checks the condition again. This is repeated until
timeout or the condition evaluates to true. To specify another interval, use the overload
AwaitCondition(Func<bool>, TimeSpan?, TimeSpan?, string, CancellationToken)
Declaration
public void AwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan? max, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
| TimeSpan? | max | The maximum duration. If undefined, uses the remaining time
(if inside a |
| CancellationToken | cancellationToken |
AwaitCondition(Func<bool>, CancellationToken)
Await until the given condition evaluates to true or until a timeout
The timeout is taken from the innermost enclosing `within` block (if inside a `within` block) or the value specified in config value "akka.test.single-expect-default". The value is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor"..
A call to conditionIsFulfilled is done immediately, then the threads sleep
for about a tenth of the timeout value, before it checks the condition again. This is repeated until
timeout or the condition evaluates to true. To specify another interval, use the overload
AwaitCondition(Func<bool>, TimeSpan?, TimeSpan?, string, CancellationToken)
Declaration
public void AwaitCondition(Func<bool> conditionIsFulfilled, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
| CancellationToken | cancellationToken |
AwaitConditionAsync(Func<bool>, TimeSpan?, TimeSpan?, string, CancellationToken)
Declaration
public Task AwaitConditionAsync(Func<bool> conditionIsFulfilled, TimeSpan? max, TimeSpan? interval, string message = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | |
| TimeSpan? | max | |
| TimeSpan? | interval | |
| string | message | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitConditionAsync(Func<bool>, TimeSpan?, string, CancellationToken)
Declaration
public Task AwaitConditionAsync(Func<bool> conditionIsFulfilled, TimeSpan? max, string message, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | |
| TimeSpan? | max | |
| string | message | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitConditionAsync(Func<bool>, CancellationToken)
Declaration
public Task AwaitConditionAsync(Func<bool> conditionIsFulfilled, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitConditionAsync(Func<Task<bool>>, TimeSpan?, TimeSpan?, string, CancellationToken)
Declaration
public Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan? max, TimeSpan? interval, string message = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<bool>> | conditionIsFulfilled | |
| TimeSpan? | max | |
| TimeSpan? | interval | |
| string | message | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitConditionAsync(Func<Task<bool>>, TimeSpan?, string, CancellationToken)
Declaration
public Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan? max, string message, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<bool>> | conditionIsFulfilled | |
| TimeSpan? | max | |
| string | message | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitConditionAsync(Func<Task<bool>>, TimeSpan?, CancellationToken)
Declaration
public Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan? max, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<bool>> | conditionIsFulfilled | |
| TimeSpan? | max | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitConditionAsync(Func<Task<bool>>, CancellationToken)
Declaration
public Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<bool>> | conditionIsFulfilled | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
AwaitConditionNoThrow(Func<bool>, TimeSpan, TimeSpan?, CancellationToken)
Await until the given condition evaluates to true or the timeout
expires, whichever comes first. Returns true if the condition was fulfilled.
The parameter interval specifies the time between calls to conditionIsFulfilled
Between calls the thread sleeps. If interval is not specified or null 100 ms is used.
Declaration
public bool AwaitConditionNoThrow(Func<bool> conditionIsFulfilled, TimeSpan max, TimeSpan? interval = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
| TimeSpan | max | The maximum duration. |
| TimeSpan? | interval | Optional. The time between calls to |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| bool | TBD |
AwaitConditionNoThrowAsync(Func<bool>, TimeSpan, TimeSpan?, CancellationToken)
Declaration
public Task<bool> AwaitConditionNoThrowAsync(Func<bool> conditionIsFulfilled, TimeSpan max, TimeSpan? interval = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | |
| TimeSpan | max | |
| TimeSpan? | interval | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
AwaitConditionNoThrowAsync(Func<Task<bool>>, TimeSpan, TimeSpan?, CancellationToken)
Declaration
public Task<bool> AwaitConditionNoThrowAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan max, TimeSpan? interval = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<bool>> | conditionIsFulfilled | |
| TimeSpan | max | |
| TimeSpan? | interval | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
ChildActorOf(Props, SupervisorStrategy, CancellationToken)
Spawns an actor as a child of this test actor with an auto-generated name, and returns the child's ActorRef.
Declaration
public IActorRef ChildActorOf(Props props, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| SupervisorStrategy | supervisorStrategy | Supervisor strategy for the child actor |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| IActorRef |
ChildActorOf(Props, string, SupervisorStrategy, CancellationToken)
Spawns an actor as a child of this test actor, and returns the child's IActorRef
Declaration
public IActorRef ChildActorOf(Props props, string name, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| string | name | Child actor name |
| SupervisorStrategy | supervisorStrategy | Supervisor strategy for the child actor |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| IActorRef |
ChildActorOf(Props, string, CancellationToken)
Spawns an actor as a child of this test actor with a stopping supervisor strategy, and returns the child's ActorRef.
Declaration
public IActorRef ChildActorOf(Props props, string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| string | name | Child actor name |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| IActorRef |
ChildActorOf(Props, CancellationToken)
Spawns an actor as a child of this test actor with an auto-generated name and stopping supervisor strategy, returning the child's ActorRef.
Declaration
public IActorRef ChildActorOf(Props props, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| IActorRef |
ChildActorOfAsync(Props, SupervisorStrategy, CancellationToken)
Spawns an actor as a child of this test actor with an auto-generated name, and returns the child's ActorRef.
Declaration
public Task<IActorRef> ChildActorOfAsync(Props props, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| SupervisorStrategy | supervisorStrategy | Supervisor strategy for the child actor |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| Task<IActorRef> |
ChildActorOfAsync(Props, string, SupervisorStrategy, CancellationToken)
Spawns an actor as a child of this test actor, and returns the child's IActorRef
Declaration
public Task<IActorRef> ChildActorOfAsync(Props props, string name, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| string | name | Child actor name |
| SupervisorStrategy | supervisorStrategy | Supervisor strategy for the child actor |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| Task<IActorRef> |
ChildActorOfAsync(Props, string, CancellationToken)
Spawns an actor as a child of this test actor with a stopping supervisor strategy, and returns the child's ActorRef.
Declaration
public Task<IActorRef> ChildActorOfAsync(Props props, string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| string | name | Child actor name |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| Task<IActorRef> |
ChildActorOfAsync(Props, CancellationToken)
Spawns an actor as a child of this test actor with an auto-generated name and stopping supervisor strategy, returning the child's ActorRef.
Declaration
public Task<IActorRef> ChildActorOfAsync(Props props, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | Child actor props |
| CancellationToken | cancellationToken | CancellationToken to cancel the operation |
Returns
| Type | Description |
|---|---|
| Task<IActorRef> |
CreateEventFilter(ActorSystem)
Creates a new event filter for the specified actor system.
Declaration
public EventFilterFactory CreateEventFilter(ActorSystem system)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | system | Actor system. |
Returns
| Type | Description |
|---|---|
| EventFilterFactory | A new instance of EventFilterFactory. |
CreateTestActor(string)
Creates a test actor with the specified name. The actor can be controlled by sending it special control messages, see TestActor.SetIgnore, TestActor.Watch, TestActor.Unwatch, TestActor.SetAutoPilot. All other messages are forwarded to the queue and can be retrieved with Receive and the ExpectMsg overloads.
The default test actor can be retrieved from the TestActor property
Declaration
public IActorRef CreateTestActor(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the new actor. |
Returns
| Type | Description |
|---|---|
| IActorRef | TBD |
CreateTestBarrier(int)
Wraps a Barrier for use in testing. It always uses a timeout when waiting. Timeouts will always throw an exception. The default timeout is 5 seconds.
Declaration
public TestBarrier CreateTestBarrier(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | TBD |
Returns
| Type | Description |
|---|---|
| TestBarrier | TBD |
CreateTestLatch(int)
Creates a Countdown latch wrapper for use in testing.
It uses a timeout when waiting and timeouts are specified as durations. There's a default timeout of 5 seconds and the default count is 1. Timeouts will always throw an exception.
Declaration
public virtual TestLatch CreateTestLatch(int count = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | Optional. The count. Default: 1 |
Returns
| Type | Description |
|---|---|
| TestLatch | A new TestLatch |
CreateTestProbe(ActorSystem, string)
Creates a new TestProbe.
Declaration
public virtual TestProbe CreateTestProbe(ActorSystem system, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | system | For multi-actor system tests, you can specify which system the node is for. |
| string | name | Optional: The name of the probe. |
Returns
| Type | Description |
|---|---|
| TestProbe | TBD |
CreateTestProbe(string)
Creates a new TestProbe.
Declaration
public virtual TestProbe CreateTestProbe(string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Optional: The name of the probe. |
Returns
| Type | Description |
|---|---|
| TestProbe | A new TestProbe instance. |
Dilated(TimeSpan)
Multiplies the duration with the TestTimeFactor, i.e. the config value "akka.test.timefactor"
Declaration
public TimeSpan Dilated(TimeSpan duration)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | TBD |
Returns
| Type | Description |
|---|---|
| TimeSpan | TBD |
ExpectMsgAllOfAsync<T>(IReadOnlyCollection<T>, CancellationToken)
Declaration
public IAsyncEnumerable<T> ExpectMsgAllOfAsync<T>(IReadOnlyCollection<T> messages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyCollection<T> | messages | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgAllOfAsync<T>(TimeSpan, IReadOnlyCollection<T>, CancellationToken)
Declaration
public IAsyncEnumerable<T> ExpectMsgAllOfAsync<T>(TimeSpan max, IReadOnlyCollection<T> messages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | |
| IReadOnlyCollection<T> | messages | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgAllOfMatchingPredicates(params PredicateInfo[])
Declaration
public IReadOnlyCollection<object> ExpectMsgAllOfMatchingPredicates(params PredicateInfo[] predicates)
Parameters
| Type | Name | Description |
|---|---|---|
| PredicateInfo[] | predicates |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<object> |
ExpectMsgAllOfMatchingPredicates(IReadOnlyCollection<PredicateInfo>, CancellationToken)
Declaration
public IReadOnlyCollection<object> ExpectMsgAllOfMatchingPredicates(IReadOnlyCollection<PredicateInfo> predicates, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyCollection<PredicateInfo> | predicates | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<object> |
ExpectMsgAllOfMatchingPredicates(TimeSpan, params PredicateInfo[])
Declaration
public IReadOnlyCollection<object> ExpectMsgAllOfMatchingPredicates(TimeSpan max, params PredicateInfo[] predicates)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | |
| PredicateInfo[] | predicates |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<object> |
ExpectMsgAllOfMatchingPredicates(TimeSpan, IReadOnlyCollection<PredicateInfo>, CancellationToken)
Declaration
public IReadOnlyCollection<object> ExpectMsgAllOfMatchingPredicates(TimeSpan max, IReadOnlyCollection<PredicateInfo> predicates, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | |
| IReadOnlyCollection<PredicateInfo> | predicates | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<object> |
ExpectMsgAllOfMatchingPredicatesAsync(IReadOnlyCollection<PredicateInfo>, CancellationToken)
Declaration
public IAsyncEnumerable<object> ExpectMsgAllOfMatchingPredicatesAsync(IReadOnlyCollection<PredicateInfo> predicates, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyCollection<PredicateInfo> | predicates | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<object> |
ExpectMsgAllOfMatchingPredicatesAsync(TimeSpan, IReadOnlyCollection<PredicateInfo>, CancellationToken)
Declaration
public IAsyncEnumerable<object> ExpectMsgAllOfMatchingPredicatesAsync(TimeSpan max, IReadOnlyCollection<PredicateInfo> predicates, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | |
| IReadOnlyCollection<PredicateInfo> | predicates | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<object> |
ExpectMsgAllOf<T>(IReadOnlyCollection<T>, CancellationToken)
Receive a number of messages from the test actor matching the given number of objects and assert that for each given object one is received which equals it and vice versa. This construct is useful when the order in which the objects are received is not fixed. Wait time is bounded by RemainingOrDefault as duration, with an assertion exception being thrown in case of timeout.
dispatcher.Tell(SomeWork1())
dispatcher.Tell(SomeWork2())
ExpectMsgAllOf(TimeSpan.FromSeconds(1), Result1(), Result2())
Declaration
public IReadOnlyCollection<T> ExpectMsgAllOf<T>(IReadOnlyCollection<T> messages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyCollection<T> | messages | The messages. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<T> | The received messages in received order |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the messages |
ExpectMsgAllOf<T>(TimeSpan, IReadOnlyCollection<T>, CancellationToken)
Receive a number of messages from the test actor matching the given number of objects and assert that for each given object one is received which equals it and vice versa. This construct is useful when the order in which the objects are received is not fixed. Wait time is bounded by the given duration, with an assertion exception being thrown in case of timeout.
dispatcher.Tell(SomeWork1())
dispatcher.Tell(SomeWork2())
ExpectMsgAllOf(TimeSpan.FromSeconds(1), Result1(), Result2())
The deadline is scaled by "akka.test.timefactor" using Dilated(TimeSpan).
Declaration
public IReadOnlyCollection<T> ExpectMsgAllOf<T>(TimeSpan max, IReadOnlyCollection<T> messages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | The deadline. The deadline is scaled by "akka.test.timefactor" using Dilated(TimeSpan). |
| IReadOnlyCollection<T> | messages | The messages. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<T> | The received messages in received order |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the messages |
ExpectMsgAllOf<T>(TimeSpan, params T[])
Declaration
public IReadOnlyCollection<T> ExpectMsgAllOf<T>(TimeSpan max, params T[] messages)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | |
| T[] | messages |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgAllOf<T>(params T[])
Declaration
public IReadOnlyCollection<T> ExpectMsgAllOf<T>(params T[] messages)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | messages |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgAnyOfAsync<T>(IEnumerable<T>, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgAnyOfAsync<T>(IEnumerable<T> messages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | messages | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgAnyOf<T>(IEnumerable<T>, CancellationToken)
Receive a message from the test actor and assert that it equals
one of the given messages. Wait time is bounded by
RemainingOrDefault as duration, with an assertion exception being thrown in case of timeout.
Declaration
public T ExpectMsgAnyOf<T>(IEnumerable<T> messages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | messages | The messages. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | The received messages in received order |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the messages |
ExpectMsgAsync<T>(Action<T, IActorRef>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor calls the action that performs extra assertions. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask<T> ExpectMsgAsync<T>(Action<T, IActorRef> assertMessageAndSender, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T, IActorRef> | assertMessageAndSender | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgAsync<T>(Action<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and calls the action that performs extra assertions. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask<T> ExpectMsgAsync<T>(Action<T> assert, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T> | assert | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgAsync<T>(Func<T, IActorRef, bool>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that the given predicate accepts it. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask<T> ExpectMsgAsync<T>(Func<T, IActorRef, bool> isMessageAndSender, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T, IActorRef, bool> | isMessageAndSender | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgAsync<T>(TimeSpan?, string, CancellationToken)
Receive one message from the test actor and assert that it is of the specified type. Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask<T> ExpectMsgAsync<T>(TimeSpan? duration = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | duration | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgAsync<T>(Predicate<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that the given predicate accepts it. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask<T> ExpectMsgAsync<T>(Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | isMessage | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgAsync<T>(T, Func<T, T, bool>, TimeSpan?, string, CancellationToken)
Receive one message from the test actor and assert that it is equal to the expected value, according to the specified comparer function.
Wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask<T> ExpectMsgAsync<T>(T expected, Func<T, T, bool> comparer, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| T | expected | TBD |
| Func<T, T, bool> | comparer | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgAsync<T>(T, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that it
equals the message.
Wait time is bounded by the given duration, if specified; otherwise
wait time is bounded by remaining time for execution of the innermost enclosing 'within'
block, if inside a 'within' block; otherwise by the config value
"akka.test.single-expect-default".
Declaration
public ValueTask<T> ExpectMsgAsync<T>(T message, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| T | message | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgFromAsync<T>(IActorRef, Action<T>, TimeSpan?, string, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, Action<T> assertMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | |
| Action<T> | assertMessage | |
| TimeSpan? | timeout | |
| string | hint | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgFromAsync<T>(IActorRef, TimeSpan?, string, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, TimeSpan? duration = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | |
| TimeSpan? | duration | |
| string | hint | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgFromAsync<T>(IActorRef, Predicate<T>, TimeSpan?, string, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | |
| Predicate<T> | isMessage | |
| TimeSpan? | timeout | |
| string | hint | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgFromAsync<T>(IActorRef, T, TimeSpan?, string, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, T message, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | |
| T | message | |
| TimeSpan? | timeout | |
| string | hint | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgFromAsync<T>(Action<IActorRef>, Action<T>, TimeSpan?, string, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(Action<IActorRef> assertSender, Action<T> assertMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<IActorRef> | assertSender | |
| Action<T> | assertMessage | |
| TimeSpan? | timeout | |
| string | hint | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgFromAsync<T>(Predicate<IActorRef>, Predicate<T>, TimeSpan?, string, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(Predicate<IActorRef> isSender, Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<IActorRef> | isSender | |
| Predicate<T> | isMessage | |
| TimeSpan? | timeout | |
| string | hint | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
ExpectMsgFrom<T>(IActorRef, Action<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor, verifies that the sender is the specified and calls the action that performs extra assertions. Wait time is bounded by the given duration if specified. If not specified, wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default". Use this variant to implement more complicated or conditional processing.
Declaration
public T ExpectMsgFrom<T>(IActorRef sender, Action<T> assertMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | TBD |
| Action<T> | assertMessage | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgFrom<T>(IActorRef, TimeSpan?, string, CancellationToken)
Receive one message from the test actor and assert that it is of the specified type and was sent by the specified sender Wait time is bounded by the given duration if specified. If not specified, wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public T ExpectMsgFrom<T>(IActorRef sender, TimeSpan? duration = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | TBD |
| TimeSpan? | duration | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgFrom<T>(IActorRef, Predicate<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that the given predicate accepts it and was sent by the specified sender Wait time is bounded by the given duration if specified. If not specified, wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default". Use this variant to implement more complicated or conditional processing.
Declaration
public T ExpectMsgFrom<T>(IActorRef sender, Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | TBD |
| Predicate<T> | isMessage | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgFrom<T>(IActorRef, T, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that it
equals the message and was sent by the specified sender
Wait time is bounded by the given duration if specified.
If not specified, wait time is bounded by remaining time for execution of the innermost enclosing 'within'
block, if inside a 'within' block; otherwise by the config value
"akka.test.single-expect-default".
Declaration
public T ExpectMsgFrom<T>(IActorRef sender, T message, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | sender | TBD |
| T | message | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgFrom<T>(Action<IActorRef>, Action<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and calls the action that performs extra assertions. Wait time is bounded by the given duration if specified. If not specified, wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default". Use this variant to implement more complicated or conditional processing.
Declaration
public T ExpectMsgFrom<T>(Action<IActorRef> assertSender, Action<T> assertMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<IActorRef> | assertSender | TBD |
| Action<T> | assertMessage | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsgFrom<T>(Predicate<IActorRef>, Predicate<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that the given
predicate accepts it and was sent by a sender that matches the isSender predicate.
Wait time is bounded by the given duration if specified.
If not specified, wait time is bounded by remaining time for execution of the innermost enclosing 'within'
block, if inside a 'within' block; otherwise by the config value
"akka.test.single-expect-default".
Use this variant to implement more complicated or conditional processing.
Declaration
public T ExpectMsgFrom<T>(Predicate<IActorRef> isSender, Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<IActorRef> | isSender | TBD |
| Predicate<T> | isMessage | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsg<T>(Action<T, IActorRef>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor calls the action that performs extra assertions. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public T ExpectMsg<T>(Action<T, IActorRef> assertMessageAndSender, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T, IActorRef> | assertMessageAndSender | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsg<T>(Action<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and calls the action that performs extra assertions. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public T ExpectMsg<T>(Action<T> assert, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T> | assert | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsg<T>(Func<T, IActorRef, bool>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that the given predicate accepts it. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public T ExpectMsg<T>(Func<T, IActorRef, bool> isMessageAndSender, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T, IActorRef, bool> | isMessageAndSender | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsg<T>(TimeSpan?, string, CancellationToken)
Receive one message from the test actor and assert that it is of the specified type. Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public T ExpectMsg<T>(TimeSpan? duration = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | duration | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsg<T>(Predicate<T>, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that the given predicate accepts it. Use this variant to implement more complicated or conditional processing.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public T ExpectMsg<T>(Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | isMessage | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsg<T>(T, Func<T, T, bool>, TimeSpan?, string, CancellationToken)
Receive one message from the test actor and assert that it is equal to the expected value, according to the specified comparer function.
Wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public T ExpectMsg<T>(T expected, Func<T, T, bool> comparer, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| T | expected | TBD |
| Func<T, T, bool> | comparer | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectMsg<T>(T, TimeSpan?, string, CancellationToken)
Receive one message of the specified type from the test actor and assert that it
equals the message.
Wait time is bounded by the given duration, if specified; otherwise
wait time is bounded by remaining time for execution of the innermost enclosing 'within'
block, if inside a 'within' block; otherwise by the config value
"akka.test.single-expect-default".
Declaration
public T ExpectMsg<T>(T message, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| T | message | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ExpectNoMsg(int, CancellationToken)
Assert that no message is received for the specified time in milliseconds.
Declaration
public void ExpectNoMsg(int milliseconds, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | milliseconds | TBD |
| CancellationToken | cancellationToken |
ExpectNoMsg(CancellationToken)
Assert that no message is received.
Wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public void ExpectNoMsg(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
ExpectNoMsg(TimeSpan, CancellationToken)
Assert that no message is received for the specified time.
Declaration
public void ExpectNoMsg(TimeSpan duration, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | TBD |
| CancellationToken | cancellationToken |
ExpectNoMsgAsync(int, CancellationToken)
Assert that no message is received for the specified time in milliseconds.
Declaration
public ValueTask ExpectNoMsgAsync(int milliseconds, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | milliseconds | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask |
ExpectNoMsgAsync(CancellationToken)
Assert that no message is received.
Wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask ExpectNoMsgAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask |
ExpectNoMsgAsync(TimeSpan, CancellationToken)
Assert that no message is received for the specified time.
Declaration
public ValueTask ExpectNoMsgAsync(TimeSpan duration, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask |
ExpectTerminated(IActorRef, TimeSpan?, string, CancellationToken)
Receive one message from the test actor and assert that it is the Terminated message of the given ActorRef.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public Terminated ExpectTerminated(IActorRef target, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | target | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Terminated | TBD |
ExpectTerminatedAsync(IActorRef, TimeSpan?, string, CancellationToken)
Receive one message from the test actor and assert that it is the Terminated message of the given ActorRef.
Wait time is bounded by the given duration, if specified; otherwise wait time is bounded by remaining time for execution of the innermost enclosing 'within' block, if inside a 'within' block; otherwise by the config value "akka.test.single-expect-default".
Declaration
public ValueTask<Terminated> ExpectTerminatedAsync(IActorRef target, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | target | TBD |
| TimeSpan? | timeout | TBD |
| string | hint | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<Terminated> | TBD |
FishForMessage(Predicate<object>, TimeSpan?, string, CancellationToken)
Receives messages until isMessage returns true.
Use it to ignore certain messages while waiting for a specific message.
Declaration
public object FishForMessage(Predicate<object> isMessage, TimeSpan? max = null, string hint = "", CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<object> | isMessage | The is message. |
| TimeSpan? | max | The maximum. |
| string | hint | The hint. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| object | Returns the message that |
FishForMessageAsync(Predicate<object>, TimeSpan?, string, CancellationToken)
Receives messages until isMessage returns true.
Use it to ignore certain messages while waiting for a specific message.
Declaration
public ValueTask<object> FishForMessageAsync(Predicate<object> isMessage, TimeSpan? max = null, string hint = "", CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<object> | isMessage | The is message. |
| TimeSpan? | max | The maximum. |
| string | hint | The hint. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<object> | Returns the message that |
FishForMessageAsync<T>(Predicate<T>, ArrayList, TimeSpan?, string, CancellationToken)
Receives messages until isMessage returns true.
Use it to ignore certain messages while waiting for a specific message.
Declaration
public ValueTask<T> FishForMessageAsync<T>(Predicate<T> isMessage, ArrayList allMessages, TimeSpan? max = null, string hint = "", CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | isMessage | The is message. |
| ArrayList | allMessages | If null then will be ignored. If not null then will be initially cleared, then filled with all the messages until |
| TimeSpan? | max | The maximum. |
| string | hint | The hint. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | Returns the message that |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the expected message. Messages of other types are ignored. |
FishForMessageAsync<T>(Predicate<T>, TimeSpan?, string, CancellationToken)
Receives messages until isMessage returns true.
Use it to ignore certain messages while waiting for a specific message.
Declaration
public ValueTask<T> FishForMessageAsync<T>(Predicate<T> isMessage, TimeSpan? max = null, string hint = "", CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | isMessage | The is message. |
| TimeSpan? | max | The maximum. |
| string | hint | The hint. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<T> | Returns the message that |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the expected message. Messages of other types are ignored. |
FishForMessage<T>(Predicate<T>, ArrayList, TimeSpan?, string, CancellationToken)
Receives messages until isMessage returns true.
Use it to ignore certain messages while waiting for a specific message.
Declaration
public T FishForMessage<T>(Predicate<T> isMessage, ArrayList allMessages, TimeSpan? max = null, string hint = "", CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | isMessage | The is message. |
| ArrayList | allMessages | If null then will be ignored. If not null then will be initially cleared, then filled with all the messages until |
| TimeSpan? | max | The maximum. |
| string | hint | The hint. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | Returns the message that |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the expected message. Messages of other types are ignored. |
FishForMessage<T>(Predicate<T>, TimeSpan?, string, CancellationToken)
Receives messages until isMessage returns true.
Use it to ignore certain messages while waiting for a specific message.
Declaration
public T FishForMessage<T>(Predicate<T> isMessage, TimeSpan? max = null, string hint = "", CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | isMessage | The is message. |
| TimeSpan? | max | The maximum. |
| string | hint | The hint. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | Returns the message that |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the expected message. Messages of other types are ignored. |
FishUntilMessageAsync<T>(TimeSpan?, CancellationToken)
Receives messages until max.
Ignores all messages except for a message of type T.
Asserts that all messages are not of the of type T.
Declaration
public Task FishUntilMessageAsync<T>(TimeSpan? max = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | Optional. The maximum wait duration. Defaults to RemainingOrDefault when unset. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Type Parameters
| Name | Description |
|---|---|
| T | The type that the message is not supposed to be. |
GetTimeoutOrDefault(TimeSpan?)
If timeout is defined it is returned; otherwise
the config value "akka.test.single-expect-default" is returned.
Declaration
public TimeSpan GetTimeoutOrDefault(TimeSpan? timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | timeout | TBD |
Returns
| Type | Description |
|---|---|
| TimeSpan | TBD |
IgnoreMessages(Func<object, bool>)
Ignore all messages in the test actor for which the given function
returns true.
Declaration
public void IgnoreMessages(Func<object, bool> shouldIgnoreMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<object, bool> | shouldIgnoreMessage | Given a message, if the function returns
|
IgnoreMessages<TMsg>()
Ignore all messages in the test actor of the given TMsg type.
Declaration
public void IgnoreMessages<TMsg>()
Type Parameters
| Name | Description |
|---|---|
| TMsg | The type of the message to ignore. |
IgnoreMessages<TMsg>(Func<TMsg, bool>)
Ignore all messages in the test actor of the given TMsg type for which the given function
returns true.
Declaration
public void IgnoreMessages<TMsg>(Func<TMsg, bool> shouldIgnoreMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TMsg, bool> | shouldIgnoreMessage | Given a message, if the function returns
|
Type Parameters
| Name | Description |
|---|---|
| TMsg | The type of the message to ignore. |
IgnoreNoMessages()
Stop ignoring messages in the test actor.
Declaration
public void IgnoreNoMessages()
InitializeTest(ActorSystem, ActorSystemSetup, string, string)
Initializes the TestKitBase.TestState for a new spec.
Declaration
protected virtual void InitializeTest(ActorSystem system, ActorSystemSetup config, string actorSystemName, string testActorName)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | system | The actor system this test will use. Can be null. |
| ActorSystemSetup | config | The configuration that |
| string | actorSystemName | The name that |
| string | testActorName | The name of the test actor. Can be null. |
InitializeTest(ActorSystem, Config, string, string)
Initializes the TestKitBase.TestState for a new spec.
Declaration
protected void InitializeTest(ActorSystem system, Config config, string actorSystemName, string testActorName)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | system | The actor system this test will use. Can be null. |
| Config | config | The configuration that |
| string | actorSystemName | The name that |
| string | testActorName | The name of the test actor. Can be null. |
InternalAwaitCondition(Func<bool>, TimeSpan, TimeSpan?, Action<string, object[]>, ILoggingAdapter, CancellationToken)
Await until the given condition evaluates to true or the timeout
expires, whichever comes first.
If no timeout is given, take it from the innermost enclosing `within` block.
Note that the timeout is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor".
The parameter interval specifies the time between calls to conditionIsFulfilled
Between calls the thread sleeps. If interval is undefined the thread only sleeps
one time, using the max as duration, and then rechecks the condition and ultimately
succeeds or fails.
To make sure that tests run as fast as possible, make sure you do not leave this value as undefined, instead set it to a relatively small value.
Declaration
protected static bool InternalAwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan max, TimeSpan? interval, Action<string, object[]> fail, ILoggingAdapter logger, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
| TimeSpan | max | The maximum duration. The value is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor". |
| TimeSpan? | interval | The time between calls to To make sure that tests run as fast as possible, make sure you do not set this value as undefined, instead set it to a relatively small value. |
| Action<string, object[]> | fail | Action that is called when the timeout expired. The parameters conforms to Format(string, params object[]) |
| ILoggingAdapter | logger | If a ILoggingAdapter is specified, debug messages will be logged using it. If |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| bool | TBD |
InternalAwaitCondition(Func<bool>, TimeSpan, TimeSpan?, Action<string, object[]>, CancellationToken)
Await until the given condition evaluates to true or the timeout
expires, whichever comes first.
If no timeout is given, take it from the innermost enclosing `within` block.
Note that the timeout is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor".
The parameter interval specifies the time between calls to conditionIsFulfilled
Between calls the thread sleeps. If interval is undefined the thread only sleeps
one time, using the max as duration, and then rechecks the condition and ultimately
succeeds or fails.
To make sure that tests run as fast as possible, make sure you do not leave this value as undefined, instead set it to a relatively small value.
Declaration
protected static bool InternalAwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan max, TimeSpan? interval, Action<string, object[]> fail, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
| TimeSpan | max | The maximum duration. The value is dilated, i.e. scaled by the factor specified in config value "akka.test.timefactor". |
| TimeSpan? | interval | The time between calls to To make sure that tests run as fast as possible, make sure you do not set this value as undefined, instead set it to a relatively small value. |
| Action<string, object[]> | fail | Action that is called when the timeout expired. The parameters conforms to Format(string, params object[]) |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| bool | TBD |
InternalAwaitConditionAsync(Func<Task<bool>>, TimeSpan, TimeSpan?, Action<string, object[]>, ILoggingAdapter, CancellationToken)
Declaration
protected static Task<bool> InternalAwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan max, TimeSpan? interval, Action<string, object[]> fail, ILoggingAdapter logger, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<bool>> | conditionIsFulfilled | |
| TimeSpan | max | |
| TimeSpan? | interval | |
| Action<string, object[]> | fail | |
| ILoggingAdapter | logger | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
InternalAwaitConditionAsync(Func<Task<bool>>, TimeSpan, TimeSpan?, Action<string, object[]>, CancellationToken)
Declaration
protected static Task<bool> InternalAwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan max, TimeSpan? interval, Action<string, object[]> fail, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<bool>> | conditionIsFulfilled | |
| TimeSpan | max | |
| TimeSpan? | interval | |
| Action<string, object[]> | fail | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
PeekOne(TimeSpan?, CancellationToken)
Peek one message from the head of the internal queue of the TestActor.
This method blocks the specified duration or until a message
is received. If no message was received, null is returned.
Declaration
public object PeekOne(TimeSpan? max = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | The maximum duration to wait.
If |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| object | The message if one was received; |
PeekOne(CancellationToken)
Peek one message from the head of the internal queue of the TestActor. This method blocks until cancelled.
Declaration
public object PeekOne(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A token used to cancel the operation |
Returns
| Type | Description |
|---|---|
| object | The message if one was received; |
PeekOneAsync(TimeSpan?, CancellationToken)
Peek one message from the head of the internal queue of the TestActor.
This method blocks the specified duration or until a message
is received. If no message was received, null is returned.
Declaration
public ValueTask<object> PeekOneAsync(TimeSpan? max = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | The maximum duration to wait.
If |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<object> | The message if one was received; |
PeekOneAsync(CancellationToken)
Peek one message from the head of the internal queue of the TestActor. This method blocks until cancelled.
Declaration
public ValueTask<object> PeekOneAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A token used to cancel the operation |
Returns
| Type | Description |
|---|---|
| ValueTask<object> | The message if one was received; |
ReceiveN(int, CancellationToken)
Receive the specified number of messages using RemainingOrDefault as timeout.
Declaration
public IReadOnlyCollection<object> ReceiveN(int numberOfMessages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | numberOfMessages | The number of messages. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<object> | The received messages |
ReceiveN(int, TimeSpan, CancellationToken)
Receive the specified number of messages in a row before the given deadline. The deadline is scaled by "akka.test.timefactor" using Dilated(TimeSpan).
Declaration
public IReadOnlyCollection<object> ReceiveN(int numberOfMessages, TimeSpan max, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | numberOfMessages | The number of messages. |
| TimeSpan | max | The timeout scaled by "akka.test.timefactor" using Dilated(TimeSpan). |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<object> | The received messages |
ReceiveNAsync(int, CancellationToken)
Receive the specified number of messages using RemainingOrDefault as timeout.
Declaration
public IAsyncEnumerable<object> ReceiveNAsync(int numberOfMessages, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | numberOfMessages | The number of messages. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<object> | The received messages |
ReceiveNAsync(int, TimeSpan, CancellationToken)
Receive the specified number of messages in a row before the given deadline. The deadline is scaled by "akka.test.timefactor" using Dilated(TimeSpan).
Declaration
public IAsyncEnumerable<object> ReceiveNAsync(int numberOfMessages, TimeSpan max, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | numberOfMessages | The number of messages. |
| TimeSpan | max | The timeout scaled by "akka.test.timefactor" using Dilated(TimeSpan). |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<object> | The received messages |
ReceiveOne(TimeSpan?, CancellationToken)
Receive one message from the internal queue of the TestActor.
This method blocks the specified duration or until a message
is received. If no message was received, null is returned.
Declaration
public object ReceiveOne(TimeSpan? max = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | The maximum duration to wait.
If |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| object | The message if one was received; |
ReceiveOneAsync(TimeSpan?, CancellationToken)
Receive one message from the internal queue of the TestActor.
This method blocks the specified duration or until a message
is received. If no message was received, null is returned.
Declaration
public ValueTask<object> ReceiveOneAsync(TimeSpan? max = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | The maximum duration to wait.
If |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<object> | The message if one was received; |
ReceiveWhileAsync<T>(Func<object, T>, TimeSpan?, TimeSpan?, int, CancellationToken)
Receive a series of messages until the function returns null or the idle timeout is met (disabled by default) or the overall maximum duration is elapsed or expected messages count is reached. Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IAsyncEnumerable<T> ReceiveWhileAsync<T>(Func<object, T> filter, TimeSpan? max = null, TimeSpan? idle = null, int msgs = 2147483647, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<object, T> | filter | TBD |
| TimeSpan? | max | TBD |
| TimeSpan? | idle | TBD |
| int | msgs | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ReceiveWhileAsync<T>(TimeSpan?, Func<object, T>, int, CancellationToken)
Receive a series of messages until the function returns null or the overall maximum duration is elapsed or expected messages count is reached. Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IAsyncEnumerable<T> ReceiveWhileAsync<T>(TimeSpan? max, Func<object, T> filter, int msgs = 2147483647, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | TBD |
| Func<object, T> | filter | TBD |
| int | msgs | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ReceiveWhileAsync<T>(TimeSpan?, TimeSpan?, Func<object, T>, int, CancellationToken)
Receive a series of messages until the function returns null or the idle timeout is met or the overall maximum duration is elapsed or expected messages count is reached. Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IAsyncEnumerable<T> ReceiveWhileAsync<T>(TimeSpan? max, TimeSpan? idle, Func<object, T> filter, int msgs = 2147483647, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | TBD |
| TimeSpan? | idle | TBD |
| Func<object, T> | filter | TBD |
| int | msgs | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ReceiveWhileAsync<T>(Predicate<T>, TimeSpan?, TimeSpan?, int, bool, CancellationToken)
Receive a series of messages.
It will continue to receive messages until the shouldContinue predicate returns false or the idle
timeout is met (disabled by default) or the overall
maximum duration is elapsed or expected messages count is reached.
If a message that isn't of type T the parameter shouldIgnoreOtherMessageTypes
declares if the message should be ignored or not.
Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IAsyncEnumerable<T> ReceiveWhileAsync<T>(Predicate<T> shouldContinue, TimeSpan? max = null, TimeSpan? idle = null, int msgs = 2147483647, bool shouldIgnoreOtherMessageTypes = true, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | shouldContinue | TBD |
| TimeSpan? | max | TBD |
| TimeSpan? | idle | TBD |
| int | msgs | TBD |
| bool | shouldIgnoreOtherMessageTypes | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ReceiveWhile<T>(Func<object, T>, TimeSpan?, TimeSpan?, int, CancellationToken)
Receive a series of messages until the function returns null or the idle timeout is met (disabled by default) or the overall maximum duration is elapsed or expected messages count is reached. Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IReadOnlyList<T> ReceiveWhile<T>(Func<object, T> filter, TimeSpan? max = null, TimeSpan? idle = null, int msgs = 2147483647, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<object, T> | filter | TBD |
| TimeSpan? | max | TBD |
| TimeSpan? | idle | TBD |
| int | msgs | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ReceiveWhile<T>(TimeSpan?, Func<object, T>, int, CancellationToken)
Receive a series of messages until the function returns null or the overall maximum duration is elapsed or expected messages count is reached. Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IReadOnlyList<T> ReceiveWhile<T>(TimeSpan? max, Func<object, T> filter, int msgs = 2147483647, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | TBD |
| Func<object, T> | filter | TBD |
| int | msgs | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ReceiveWhile<T>(TimeSpan?, TimeSpan?, Func<object, T>, int, CancellationToken)
Receive a series of messages until the function returns null or the idle timeout is met or the overall maximum duration is elapsed or expected messages count is reached. Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IReadOnlyList<T> ReceiveWhile<T>(TimeSpan? max, TimeSpan? idle, Func<object, T> filter, int msgs = 2147483647, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | TBD |
| TimeSpan? | idle | TBD |
| Func<object, T> | filter | TBD |
| int | msgs | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ReceiveWhile<T>(Predicate<T>, TimeSpan?, TimeSpan?, int, bool, CancellationToken)
Receive a series of messages.
It will continue to receive messages until the shouldContinue predicate returns false or the idle
timeout is met (disabled by default) or the overall
maximum duration is elapsed or expected messages count is reached.
If a message that isn't of type T the parameter shouldIgnoreOtherMessageTypes
declares if the message should be ignored or not.
Returns the sequence of messages.
Note that it is not an error to hit the max duration in this case.
The max duration is scaled by Dilated(TimeSpan)
Declaration
public IReadOnlyList<T> ReceiveWhile<T>(Predicate<T> shouldContinue, TimeSpan? max = null, TimeSpan? idle = null, int msgs = 2147483647, bool shouldIgnoreOtherMessageTypes = true, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Predicate<T> | shouldContinue | TBD |
| TimeSpan? | max | TBD |
| TimeSpan? | idle | TBD |
| int | msgs | TBD |
| bool | shouldIgnoreOtherMessageTypes | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
RemainingOr(TimeSpan)
If inside a within block obtain time remaining for execution of the innermost enclosing within
block; otherwise returns the given duration.
Declaration
protected TimeSpan RemainingOr(TimeSpan duration)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | TBD |
Returns
| Type | Description |
|---|---|
| TimeSpan | TBD |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | TBD |
RemainingOrDilated(TimeSpan?)
If duration is finite it is returned after it has been scaled using Dilated(TimeSpan).
If duration is undefined, it returns the remaining time (if within a within block) or the properly dilated
default from settings (key "akka.test.single-expect-default").
If duration is infinite, an ArgumentException is thrown.
Declaration
public TimeSpan RemainingOrDilated(TimeSpan? duration)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | duration | The maximum. |
Returns
| Type | Description |
|---|---|
| TimeSpan | A finite TimeSpan properly dilated |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
SetAutoPilot(AutoPilot)
Install an AutoPilot to drive the TestActor. The AutoPilot will be run for each received message and can be used to send or forward messages, etc.
Each invocation must return the AutoPilot for the next round. To reuse the same AutoPilot return KeepRunning.
Declaration
public void SetAutoPilot(AutoPilot pilot)
Parameters
| Type | Name | Description |
|---|---|---|
| AutoPilot | pilot | The pilot to install. |
Shutdown(ActorSystem, TimeSpan?, bool)
Shuts down the specified system. On failure debug output will be logged about the remaining actors in the system. If verifySystemShutdown is true, then an exception will be thrown on failure.
Declaration
protected virtual void Shutdown(ActorSystem system, TimeSpan? duration = null, bool verifySystemShutdown = false)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | system | The system to shutdown. |
| TimeSpan? | duration | The duration to wait for shutdown. Default is 5 seconds multiplied with the config value "akka.test.timefactor" |
| bool | verifySystemShutdown | if set to |
Exceptions
| Type | Condition |
|---|---|
| TimeoutException | TBD |
Shutdown(TimeSpan?, bool)
Shuts down this system. On failure debug output will be logged about the remaining actors in the system. If verifySystemShutdown is true, then an exception will be thrown on failure.
Declaration
public virtual void Shutdown(TimeSpan? duration = null, bool verifySystemShutdown = false)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | duration | Optional. The duration to wait for shutdown. Default is 5 seconds multiplied with the config value "akka.test.timefactor". |
| bool | verifySystemShutdown | if set to |
Exceptions
| Type | Condition |
|---|---|
| TimeoutException | TBD |
TryPeekOne(out MessageEnvelope, TimeSpan?, CancellationToken)
Peek one message from the head of the internal queue of the TestActor within the specified duration.
True is returned if a message existed, and the message
is returned in envelope. The method blocks the
specified duration, and can be cancelled using the
cancellationToken.
Declaration
public bool TryPeekOne(out MessageEnvelope envelope, TimeSpan? max, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageEnvelope | envelope | The received envelope. |
| TimeSpan? | max | The maximum duration to wait.
If |
| CancellationToken | cancellationToken | A token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| bool |
|
TryPeekOneAsync(TimeSpan?, CancellationToken)
Peek one message from the head of the internal queue of the TestActor within the specified duration.
True is returned if a message existed, and the message
is returned in envelope. The method blocks the
specified duration, and can be cancelled using the
cancellationToken.
Declaration
public ValueTask<(bool success, MessageEnvelope envelope)> TryPeekOneAsync(TimeSpan? max, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | The maximum duration to wait.
If |
| CancellationToken | cancellationToken | A token used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<(bool success, MessageEnvelope envelope)> |
|
TryReceiveOne(out MessageEnvelope, TimeSpan?, CancellationToken)
Receive one message from the internal queue of the TestActor within
the specified duration. The method blocks the specified duration.
envelope
is a MessageEnvelope containing the sender and the message.
Declaration
public bool TryReceiveOne(out MessageEnvelope envelope, TimeSpan? max = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageEnvelope | envelope | The received envelope. |
| TimeSpan? | max | Optional: The maximum duration to wait.
If |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| bool |
|
TryReceiveOneAsync(TimeSpan?, CancellationToken)
Receive one message from the internal queue of the TestActor within
the specified duration. The method blocks the specified duration.
envelope
is a MessageEnvelope containing the sender and the message.
Declaration
public ValueTask<(bool success, MessageEnvelope envelope)> TryReceiveOneAsync(TimeSpan? max, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | Optional: The maximum duration to wait.
If |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask<(bool success, MessageEnvelope envelope)> |
|
Unwatch(IActorRef)
Have the TestActor stop watching an actor.
Declaration
public IActorRef Unwatch(IActorRef actorToUnwatch)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorToUnwatch | The actor to unwatch. |
Returns
| Type | Description |
|---|---|
| IActorRef | The actor to unwatch, i.e. the parameter |
UnwatchAsync(IActorRef)
Have the TestActor stop watching an actor.
Declaration
public Task<IActorRef> UnwatchAsync(IActorRef actorToUnwatch)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorToUnwatch | The actor to unwatch. |
Returns
| Type | Description |
|---|---|
| Task<IActorRef> | The actor to unwatch, i.e. the parameter |
Remarks
This method exists in order to make the asynchronous nature of the Unwatch method explicit.
WaitForRadioSilenceAsync(TimeSpan?, uint?, CancellationToken)
Waits for a max period of 'radio-silence' limited to a number of maxMessages.
Note: 'radio-silence' definition: period when no messages arrive at.
Declaration
public Task<ArrayList> WaitForRadioSilenceAsync(TimeSpan? max = null, uint? maxMessages = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan? | max | A temporary period of 'radio-silence'. |
| uint? | maxMessages | The method asserts that |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ArrayList> | Returns all the messages encountered before 'radio-silence' was reached. |
Watch(IActorRef)
Have the TestActor watch an actor and receive Terminated messages when the actor terminates.
Declaration
public IActorRef Watch(IActorRef actorToWatch)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorToWatch | The actor to watch. |
Returns
| Type | Description |
|---|---|
| IActorRef | The actor to watch, i.e. the parameter |
WatchAsync(IActorRef)
Have the TestActor watch an actor and receive Terminated messages when the actor terminates.
Declaration
public Task<IActorRef> WatchAsync(IActorRef actorToWatch)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorToWatch | The actor to watch. |
Returns
| Type | Description |
|---|---|
| Task<IActorRef> | The actor to watch, i.e. the parameter |
Remarks
This method exists in order to make the asynchronous nature of the Watch method explicit.
Within(TimeSpan, Action, TimeSpan?, CancellationToken)
Execute code block while bounding its execution time between 0 seconds and max.
`within` blocks may be nested. All methods in this class which take maximum wait times are available in a version which implicitly uses the remaining time governed by the innermost enclosing `within` block.
Declaration
public void Within(TimeSpan max, Action action, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | TBD |
| Action | action | TBD |
| TimeSpan? | epsilonValue | TBD |
| CancellationToken | cancellationToken |
Within(TimeSpan, TimeSpan, Action, string, TimeSpan?, CancellationToken)
Execute code block while bounding its execution time between min and max.
`within` blocks may be nested. All methods in this class which take maximum wait times are available in a version which implicitly uses the remaining time governed by the innermost enclosing `within` block.
Declaration
public void Within(TimeSpan min, TimeSpan max, Action action, string hint = null, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | min | TBD |
| TimeSpan | max | TBD |
| Action | action | TBD |
| string | hint | TBD |
| TimeSpan? | epsilonValue | TBD |
| CancellationToken | cancellationToken |
WithinAsync(TimeSpan, Func<Task>, TimeSpan?, CancellationToken)
Async version of Within(TimeSpan, Action, TimeSpan?, CancellationToken) that takes a Func<TResult> instead of an Action
Declaration
public Task WithinAsync(TimeSpan max, Func<Task> actionAsync, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | |
| Func<Task> | actionAsync | |
| TimeSpan? | epsilonValue | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
WithinAsync(TimeSpan, TimeSpan, Func<Task>, string, TimeSpan?, CancellationToken)
Async version of Within(TimeSpan, TimeSpan, Action, string, TimeSpan?, CancellationToken) that takes a Func<TResult> instead of an Action
Declaration
public Task WithinAsync(TimeSpan min, TimeSpan max, Func<Task> actionAsync, string hint = null, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | min | |
| TimeSpan | max | |
| Func<Task> | actionAsync | |
| string | hint | |
| TimeSpan? | epsilonValue | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
WithinAsync<T>(TimeSpan, Func<Task<T>>, TimeSpan?, CancellationToken)
Execute code block while bounding its execution time between 0 seconds and max.
`within` blocks may be nested. All methods in this class which take maximum wait times are available in a version which implicitly uses the remaining time governed by the innermost enclosing `within` block.
Declaration
public Task<T> WithinAsync<T>(TimeSpan max, Func<Task<T>> function, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | TBD |
| Func<Task<T>> | function | TBD |
| TimeSpan? | epsilonValue | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
WithinAsync<T>(TimeSpan, TimeSpan, Func<Task<T>>, string, TimeSpan?, CancellationToken)
Execute code block while bounding its execution time between min and max.
`within` blocks may be nested. All methods in this class which take maximum wait times are available in a version which implicitly uses the remaining time governed by the innermost enclosing `within` block.
Note that the max duration is scaled using Dilated(TimeSpan) which uses the config value "akka.test.timefactor".
Note that due to how asynchronous Task is executed in managed code, there is no way to stop a running Task.
If this assertion fails in any way, the function Task might still be running in the
background and might not be stopped/disposed until the unit test is over.
Declaration
public Task<T> WithinAsync<T>(TimeSpan min, TimeSpan max, Func<Task<T>> function, string hint = null, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | min | TBD |
| TimeSpan | max | TBD |
| Func<Task<T>> | function | TBD |
| string | hint | TBD |
| TimeSpan? | epsilonValue | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
Within<T>(TimeSpan, Func<T>, TimeSpan?, CancellationToken)
Execute code block while bounding its execution time between 0 seconds and max.
`within` blocks may be nested. All methods in this class which take maximum wait times are available in a version which implicitly uses the remaining time governed by the innermost enclosing `within` block.
Declaration
public T Within<T>(TimeSpan max, Func<T> function, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | max | TBD |
| Func<T> | function | TBD |
| TimeSpan? | epsilonValue | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
Within<T>(TimeSpan, TimeSpan, Func<T>, string, TimeSpan?, CancellationToken)
Execute code block while bounding its execution time between min and max.
`within` blocks may be nested. All methods in this class which take maximum wait times are available in a version which implicitly uses the remaining time governed by the innermost enclosing `within` block.
Declaration
public T Within<T>(TimeSpan min, TimeSpan max, Func<T> function, string hint = null, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | min | TBD |
| TimeSpan | max | TBD |
| Func<T> | function | TBD |
| string | hint | TBD |
| TimeSpan? | epsilonValue | TBD |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
Edit this page