Class TestKitBase
Implements
Inherited Members
Namespace: Akka.TestKit
Assembly: Akka.TestKit.dll
Syntax
public abstract class TestKitBase : IActorRefFactory
Constructors
| Improve this Doc 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
| Improve this Doc 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 |
---|---|
Boolean |
|
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
| Improve this Doc 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 |
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 |
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, Boolean)
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. |
Boolean | 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, Boolean)
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. |
Boolean | 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, Boolean)
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. |
Boolean | 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, Boolean)
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. |
Boolean | 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, Boolean)
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. |
Boolean | 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, Boolean)
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. |
Boolean | 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 |
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, Nullable<TimeSpan>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action | assertion | The action. |
Nullable<TimeSpan> | duration | The timeout. |
Nullable<TimeSpan> | interval | The interval to wait between executing the assertion. |
CancellationToken | cancellationToken |
AwaitAssertAsync(Action, Nullable<TimeSpan>, Nullable<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 async Task AwaitAssertAsync(Action assertion, TimeSpan? duration = null, TimeSpan? interval = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action | assertion | The action. |
Nullable<TimeSpan> | duration | The timeout. |
Nullable<TimeSpan> | interval | The interval to wait between executing the assertion. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitAssertAsync(Func<Task>, Nullable<TimeSpan>, Nullable<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 async Task AwaitAssertAsync(Func<Task> assertion, TimeSpan? duration = null, TimeSpan? interval = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | assertion | The action. |
Nullable<TimeSpan> | duration | The timeout. |
Nullable<TimeSpan> | interval | The interval to wait between executing the assertion. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitCondition(Func<Boolean>, Nullable<TimeSpan>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
Nullable<TimeSpan> | max | The maximum duration. If undefined, uses the remaining time
(if inside a |
Nullable<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<Boolean>, Nullable<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<Boolean>, Nullable<TimeSpan>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public void AwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan? max, string message, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
Nullable<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<Boolean>, Nullable<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<Boolean>, Nullable<TimeSpan>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public void AwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan? max, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
Nullable<TimeSpan> | max | The maximum duration. If undefined, uses the remaining time
(if inside a |
CancellationToken | cancellationToken |
AwaitCondition(Func<Boolean>, 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<Boolean>, Nullable<TimeSpan>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public void AwaitCondition(Func<bool> conditionIsFulfilled, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
CancellationToken | cancellationToken |
AwaitConditionAsync(Func<Boolean>, Nullable<TimeSpan>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public async Task AwaitConditionAsync(Func<bool> conditionIsFulfilled, TimeSpan? max, TimeSpan? interval, string message = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | |
Nullable<TimeSpan> | max | |
Nullable<TimeSpan> | interval | |
String | message | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitConditionAsync(Func<Boolean>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public async Task AwaitConditionAsync(Func<bool> conditionIsFulfilled, TimeSpan? max, string message, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | |
Nullable<TimeSpan> | max | |
String | message | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitConditionAsync(Func<Boolean>, CancellationToken)
Declaration
public async Task AwaitConditionAsync(Func<bool> conditionIsFulfilled, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitConditionAsync(Func<Task<Boolean>>, Nullable<TimeSpan>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public async Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan? max, TimeSpan? interval, string message = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task<Boolean>> | conditionIsFulfilled | |
Nullable<TimeSpan> | max | |
Nullable<TimeSpan> | interval | |
String | message | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitConditionAsync(Func<Task<Boolean>>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public async Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan? max, string message, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task<Boolean>> | conditionIsFulfilled | |
Nullable<TimeSpan> | max | |
String | message | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitConditionAsync(Func<Task<Boolean>>, Nullable<TimeSpan>, CancellationToken)
Declaration
public async Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan? max, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task<Boolean>> | conditionIsFulfilled | |
Nullable<TimeSpan> | max | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitConditionAsync(Func<Task<Boolean>>, CancellationToken)
Declaration
public async Task AwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task<Boolean>> | conditionIsFulfilled | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
AwaitConditionNoThrow(Func<Boolean>, TimeSpan, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | The condition that must be fulfilled within the duration. |
TimeSpan | max | The maximum duration. |
Nullable<TimeSpan> | interval | Optional. The time between calls to |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Boolean | TBD |
AwaitConditionNoThrowAsync(Func<Boolean>, TimeSpan, Nullable<TimeSpan>, CancellationToken)
Declaration
public Task<bool> AwaitConditionNoThrowAsync(Func<bool> conditionIsFulfilled, TimeSpan max, TimeSpan? interval = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | conditionIsFulfilled | |
TimeSpan | max | |
Nullable<TimeSpan> | interval | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Boolean> |
AwaitConditionNoThrowAsync(Func<Task<Boolean>>, TimeSpan, Nullable<TimeSpan>, CancellationToken)
Declaration
public Task<bool> AwaitConditionNoThrowAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan max, TimeSpan? interval = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task<Boolean>> | conditionIsFulfilled | |
TimeSpan | max | |
Nullable<TimeSpan> | interval | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Boolean> |
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(CancellationToken))
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(CancellationToken))
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(CancellationToken))
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(CancellationToken))
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 async Task<IActorRef> ChildActorOfAsync(Props props, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default(CancellationToken))
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 async Task<IActorRef> ChildActorOfAsync(Props props, string name, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default(CancellationToken))
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 async Task<IActorRef> ChildActorOfAsync(Props props, string name, CancellationToken cancellationToken = default(CancellationToken))
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 async Task<IActorRef> ChildActorOfAsync(Props props, CancellationToken cancellationToken = default(CancellationToken))
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(Int32)
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 |
---|---|---|
Int32 | count | TBD |
Returns
Type | Description |
---|---|
TestBarrier | TBD |
CreateTestLatch(Int32)
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 |
---|---|---|
Int32 | 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 |
ExpectMsg<T>(T, Func<T, T, Boolean>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
T | expected | TBD |
Func<T, T, Boolean> | comparer | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsg<T>(T, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
T | message | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsg<T>(Action<T, IActorRef>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action<T, IActorRef> | assertMessageAndSender | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsg<T>(Action<T>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action<T> | assert | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsg<T>(Func<T, IActorRef, Boolean>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<T, IActorRef, Boolean> | isMessageAndSender | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsg<T>(Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | duration | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsg<T>(Predicate<T>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | isMessage | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgAllOf<T>(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 |
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(CancellationToken))
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, 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>(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(CancellationToken))
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 |
ExpectMsgAllOfAsync<T>(IReadOnlyCollection<T>, CancellationToken)
Declaration
public async IAsyncEnumerable<T> ExpectMsgAllOfAsync<T>(IReadOnlyCollection<T> messages, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<T> | messages | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgAllOfAsync<T>(TimeSpan, IReadOnlyCollection<T>, CancellationToken)
Declaration
public async IAsyncEnumerable<T> ExpectMsgAllOfAsync<T>(TimeSpan max, IReadOnlyCollection<T> messages, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | max | |
IReadOnlyCollection<T> | messages | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgAllOfMatchingPredicates(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, 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 async IAsyncEnumerable<object> ExpectMsgAllOfMatchingPredicatesAsync(IReadOnlyCollection<PredicateInfo> predicates, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<PredicateInfo> | predicates | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<Object> |
ExpectMsgAllOfMatchingPredicatesAsync(TimeSpan, IReadOnlyCollection<PredicateInfo>, CancellationToken)
Declaration
public async IAsyncEnumerable<object> ExpectMsgAllOfMatchingPredicatesAsync(TimeSpan max, IReadOnlyCollection<PredicateInfo> predicates, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | max | |
IReadOnlyCollection<PredicateInfo> | predicates | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<Object> |
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(CancellationToken))
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 |
ExpectMsgAnyOfAsync<T>(IEnumerable<T>, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgAnyOfAsync<T>(IEnumerable<T> messages, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | messages | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgAsync<T>(T, Func<T, T, Boolean>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
T | expected | TBD |
Func<T, T, Boolean> | comparer | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgAsync<T>(T, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
T | message | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgAsync<T>(Action<T, IActorRef>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action<T, IActorRef> | assertMessageAndSender | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgAsync<T>(Action<T>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action<T> | assert | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgAsync<T>(Func<T, IActorRef, Boolean>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<T, IActorRef, Boolean> | isMessageAndSender | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgAsync<T>(Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | duration | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgAsync<T>(Predicate<T>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | isMessage | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgFrom<T>(IActorRef, T, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | TBD |
T | message | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgFrom<T>(IActorRef, Action<T>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | TBD |
Action<T> | assertMessage | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgFrom<T>(IActorRef, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | TBD |
Nullable<TimeSpan> | duration | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgFrom<T>(IActorRef, Predicate<T>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | TBD |
Predicate<T> | isMessage | TBD |
Nullable<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>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action<IActorRef> | assertSender | TBD |
Action<T> | assertMessage | TBD |
Nullable<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>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<IActorRef> | isSender | TBD |
Predicate<T> | isMessage | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ExpectMsgFromAsync<T>(IActorRef, T, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, T message, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | |
T | message | |
Nullable<TimeSpan> | timeout | |
String | hint | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgFromAsync<T>(IActorRef, Action<T>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, Action<T> assertMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | |
Action<T> | assertMessage | |
Nullable<TimeSpan> | timeout | |
String | hint | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgFromAsync<T>(IActorRef, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, TimeSpan? duration = null, string hint = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | |
Nullable<TimeSpan> | duration | |
String | hint | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgFromAsync<T>(IActorRef, Predicate<T>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(IActorRef sender, Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | sender | |
Predicate<T> | isMessage | |
Nullable<TimeSpan> | timeout | |
String | hint | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgFromAsync<T>(Action<IActorRef>, Action<T>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(Action<IActorRef> assertSender, Action<T> assertMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Action<IActorRef> | assertSender | |
Action<T> | assertMessage | |
Nullable<TimeSpan> | timeout | |
String | hint | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectMsgFromAsync<T>(Predicate<IActorRef>, Predicate<T>, Nullable<TimeSpan>, String, CancellationToken)
Declaration
public ValueTask<T> ExpectMsgFromAsync<T>(Predicate<IActorRef> isSender, Predicate<T> isMessage, TimeSpan? timeout = null, string hint = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<IActorRef> | isSender | |
Predicate<T> | isMessage | |
Nullable<TimeSpan> | timeout | |
String | hint | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> |
Type Parameters
Name | Description |
---|---|
T |
ExpectNoMsg(Int32, CancellationToken)
Assert that no message is received for the specified time in milliseconds.
Declaration
public void ExpectNoMsg(int milliseconds, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | 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(CancellationToken))
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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | duration | TBD |
CancellationToken | cancellationToken |
ExpectNoMsgAsync(Int32, CancellationToken)
Assert that no message is received for the specified time in milliseconds.
Declaration
public ValueTask ExpectNoMsgAsync(int milliseconds, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | milliseconds | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask |
ExpectNoMsgAsync(TimeSpan, CancellationToken)
Assert that no message is received for the specified time.
Declaration
public ValueTask ExpectNoMsgAsync(TimeSpan duration, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | duration | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask |
ExpectTerminated(IActorRef, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | target | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Terminated | TBD |
ExpectTerminatedAsync(IActorRef, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IActorRef | target | TBD |
Nullable<TimeSpan> | timeout | TBD |
String | hint | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<Terminated> | TBD |
FishForMessage(Predicate<Object>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<Object> | isMessage | The is message. |
Nullable<TimeSpan> | max | The maximum. |
String | hint | The hint. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Object | Returns the message that |
FishForMessage<T>(Predicate<T>, ArrayList, Nullable<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(CancellationToken))
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 |
Nullable<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>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | isMessage | The is message. |
Nullable<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. |
FishForMessageAsync(Predicate<Object>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<Object> | isMessage | The is message. |
Nullable<TimeSpan> | max | The maximum. |
String | hint | The hint. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<Object> | Returns the message that |
FishForMessageAsync<T>(Predicate<T>, ArrayList, Nullable<TimeSpan>, String, CancellationToken)
Receives messages until isMessage
returns true
.
Use it to ignore certain messages while waiting for a specific message.
Declaration
public async ValueTask<T> FishForMessageAsync<T>(Predicate<T> isMessage, ArrayList allMessages, TimeSpan? max = null, string hint = "", CancellationToken cancellationToken = default(CancellationToken))
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 |
Nullable<TimeSpan> | max | The maximum. |
String | hint | The hint. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.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>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | isMessage | The is message. |
Nullable<TimeSpan> | max | The maximum. |
String | hint | The hint. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<T> | Returns the message that |
Type Parameters
Name | Description |
---|---|
T | The type of the expected message. Messages of other types are ignored. |
FishUntilMessageAsync<T>(Nullable<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 async Task FishUntilMessageAsync<T>(TimeSpan? max = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<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(Nullable<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 |
---|---|---|
Nullable<TimeSpan> | timeout | TBD |
Returns
Type | Description |
---|---|
TimeSpan | TBD |
IgnoreMessages(Func<Object, Boolean>)
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, Boolean> | 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, Boolean>)
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, Boolean> | 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 Akka.TestKit.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 Akka.TestKit.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<Boolean>, TimeSpan, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | 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". |
Nullable<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, Object[]) |
ILoggingAdapter | logger | If a ILoggingAdapter is specified, debug messages will be logged using it. If |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Boolean | TBD |
InternalAwaitCondition(Func<Boolean>, TimeSpan, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | 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". |
Nullable<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, Object[]) |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Boolean | TBD |
InternalAwaitConditionAsync(Func<Task<Boolean>>, TimeSpan, Nullable<TimeSpan>, Action<String, Object[]>, ILoggingAdapter, CancellationToken)
Declaration
protected static async Task<bool> InternalAwaitConditionAsync(Func<Task<bool>> conditionIsFulfilled, TimeSpan max, TimeSpan? interval, Action<string, object[]> fail, ILoggingAdapter logger, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task<Boolean>> | conditionIsFulfilled | |
TimeSpan | max | |
Nullable<TimeSpan> | interval | |
Action<String, Object[]> | fail | |
ILoggingAdapter | logger | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Boolean> |
InternalAwaitConditionAsync(Func<Task<Boolean>>, TimeSpan, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Task<Boolean>> | conditionIsFulfilled | |
TimeSpan | max | |
Nullable<TimeSpan> | interval | |
Action<String, Object[]> | fail | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Boolean> |
PeekOne(Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<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(Nullable<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 async ValueTask<object> PeekOneAsync(TimeSpan? max = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | The maximum duration to wait.
If |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.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 async ValueTask<object> PeekOneAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | A token used to cancel the operation |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<Object> | The message if one was received; |
ReceiveN(Int32, CancellationToken)
Receive the specified number of messages using RemainingOrDefault as timeout.
Declaration
public IReadOnlyCollection<object> ReceiveN(int numberOfMessages, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | numberOfMessages | The number of messages. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
IReadOnlyCollection<Object> | The received messages |
ReceiveN(Int32, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | 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(Int32, CancellationToken)
Receive the specified number of messages using RemainingOrDefault as timeout.
Declaration
public async IAsyncEnumerable<object> ReceiveNAsync(int numberOfMessages, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | numberOfMessages | The number of messages. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<Object> | The received messages |
ReceiveNAsync(Int32, 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 async IAsyncEnumerable<object> ReceiveNAsync(int numberOfMessages, TimeSpan max, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | numberOfMessages | The number of messages. |
TimeSpan | max | The timeout scaled by "akka.test.timefactor" using Dilated(TimeSpan). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<Object> | The received messages |
ReceiveOne(Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | The maximum duration to wait.
If |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Object | The message if one was received; |
ReceiveOneAsync(Nullable<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 async ValueTask<object> ReceiveOneAsync(TimeSpan? max = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | The maximum duration to wait.
If |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<Object> | The message if one was received; |
ReceiveWhile<T>(Func<Object, T>, Nullable<TimeSpan>, Nullable<TimeSpan>, Int32, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Object, T> | filter | TBD |
Nullable<TimeSpan> | max | TBD |
Nullable<TimeSpan> | idle | TBD |
Int32 | msgs | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
IReadOnlyList<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ReceiveWhile<T>(Nullable<TimeSpan>, Func<Object, T>, Int32, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | TBD |
Func<Object, T> | filter | TBD |
Int32 | msgs | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
IReadOnlyList<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ReceiveWhile<T>(Nullable<TimeSpan>, Nullable<TimeSpan>, Func<Object, T>, Int32, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | TBD |
Nullable<TimeSpan> | idle | TBD |
Func<Object, T> | filter | TBD |
Int32 | msgs | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
IReadOnlyList<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ReceiveWhile<T>(Predicate<T>, Nullable<TimeSpan>, Nullable<TimeSpan>, Int32, Boolean, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | shouldContinue | TBD |
Nullable<TimeSpan> | max | TBD |
Nullable<TimeSpan> | idle | TBD |
Int32 | msgs | TBD |
Boolean | shouldIgnoreOtherMessageTypes | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
IReadOnlyList<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ReceiveWhileAsync<T>(Func<Object, T>, Nullable<TimeSpan>, Nullable<TimeSpan>, Int32, 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 async IAsyncEnumerable<T> ReceiveWhileAsync<T>(Func<object, T> filter, TimeSpan? max = null, TimeSpan? idle = null, int msgs = 2147483647, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Func<Object, T> | filter | TBD |
Nullable<TimeSpan> | max | TBD |
Nullable<TimeSpan> | idle | TBD |
Int32 | msgs | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ReceiveWhileAsync<T>(Nullable<TimeSpan>, Func<Object, T>, Int32, 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 async IAsyncEnumerable<T> ReceiveWhileAsync<T>(TimeSpan? max, Func<object, T> filter, int msgs = 2147483647, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | TBD |
Func<Object, T> | filter | TBD |
Int32 | msgs | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ReceiveWhileAsync<T>(Nullable<TimeSpan>, Nullable<TimeSpan>, Func<Object, T>, Int32, 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 async IAsyncEnumerable<T> ReceiveWhileAsync<T>(TimeSpan? max, TimeSpan? idle, Func<object, T> filter, int msgs = 2147483647, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | TBD |
Nullable<TimeSpan> | idle | TBD |
Func<Object, T> | filter | TBD |
Int32 | msgs | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
ReceiveWhileAsync<T>(Predicate<T>, Nullable<TimeSpan>, Nullable<TimeSpan>, Int32, Boolean, 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 async IAsyncEnumerable<T> ReceiveWhileAsync<T>(Predicate<T> shouldContinue, TimeSpan? max = null, TimeSpan? idle = null, int msgs = 2147483647, bool shouldIgnoreOtherMessageTypes = true, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | shouldContinue | TBD |
Nullable<TimeSpan> | max | TBD |
Nullable<TimeSpan> | idle | TBD |
Int32 | msgs | TBD |
Boolean | shouldIgnoreOtherMessageTypes | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<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(Nullable<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 |
---|---|---|
Nullable<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, Nullable<TimeSpan>, Boolean)
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. |
Nullable<TimeSpan> | duration | The duration to wait for shutdown. Default is 5 seconds multiplied with the config value "akka.test.timefactor" |
Boolean | verifySystemShutdown | if set to |
Exceptions
Type | Condition |
---|---|
TimeoutException | TBD |
Shutdown(Nullable<TimeSpan>, Boolean)
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 |
---|---|---|
Nullable<TimeSpan> | duration | Optional. The duration to wait for shutdown. Default is 5 seconds multiplied with the config value "akka.test.timefactor". |
Boolean | verifySystemShutdown | if set to |
Exceptions
Type | Condition |
---|---|
TimeoutException | TBD |
TryPeekOne(out MessageEnvelope, Nullable<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. |
Nullable<TimeSpan> | max | The maximum duration to wait.
If |
CancellationToken | cancellationToken | A token used to cancel the operation. |
Returns
Type | Description |
---|---|
Boolean |
|
TryPeekOneAsync(Nullable<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 |
---|---|---|
Nullable<TimeSpan> | max | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.ValueTuple<Boolean, MessageEnvelope>> |
|
TryReceiveOne(out MessageEnvelope, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
MessageEnvelope | envelope | The received envelope. |
Nullable<TimeSpan> | max | Optional: The maximum duration to wait.
If |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Boolean |
|
TryReceiveOneAsync(Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.ValueTuple<Boolean, MessageEnvelope>> |
|
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 async 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(Nullable<TimeSpan>, Nullable<UInt32>, 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 async Task<ArrayList> WaitForRadioSilenceAsync(TimeSpan? max = null, uint? maxMessages = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | max | A temporary period of 'radio-silence'. |
Nullable<UInt32> | 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 async 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, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | max | TBD |
Action | action | TBD |
Nullable<TimeSpan> | epsilonValue | TBD |
CancellationToken | cancellationToken |
Within(TimeSpan, TimeSpan, Action, String, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | min | TBD |
TimeSpan | max | TBD |
Action | action | TBD |
String | hint | TBD |
Nullable<TimeSpan> | epsilonValue | TBD |
CancellationToken | cancellationToken |
Within<T>(TimeSpan, Func<T>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | max | TBD |
Func<T> | function | TBD |
Nullable<TimeSpan> | epsilonValue | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
Within<T>(TimeSpan, TimeSpan, Func<T>, String, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | min | TBD |
TimeSpan | max | TBD |
Func<T> | function | TBD |
String | hint | TBD |
Nullable<TimeSpan> | epsilonValue | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
T | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
WithinAsync(TimeSpan, Func<Task>, Nullable<TimeSpan>, CancellationToken)
Async version of Within(TimeSpan, Action, Nullable<TimeSpan>, CancellationToken) that takes a Func<TResult> instead of an Action
Declaration
public async Task WithinAsync(TimeSpan max, Func<Task> actionAsync, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | max | |
Func<Task> | actionAsync | |
Nullable<TimeSpan> | epsilonValue | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
WithinAsync(TimeSpan, TimeSpan, Func<Task>, String, Nullable<TimeSpan>, CancellationToken)
Async version of Within(TimeSpan, TimeSpan, Action, String, Nullable<TimeSpan>, CancellationToken) that takes a Func<TResult> instead of an Action
Declaration
public async Task WithinAsync(TimeSpan min, TimeSpan max, Func<Task> actionAsync, string hint = null, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | min | |
TimeSpan | max | |
Func<Task> | actionAsync | |
String | hint | |
Nullable<TimeSpan> | epsilonValue | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
WithinAsync<T>(TimeSpan, Func<Task<T>>, Nullable<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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | max | TBD |
Func<Task<T>> | function | TBD |
Nullable<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, Nullable<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 async Task<T> WithinAsync<T>(TimeSpan min, TimeSpan max, Func<Task<T>> function, string hint = null, TimeSpan? epsilonValue = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | min | TBD |
TimeSpan | max | TBD |
Func<Task<T>> | function | TBD |
String | hint | TBD |
Nullable<TimeSpan> | epsilonValue | TBD |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<T> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |