Table of Contents

Class TestActorRef<TActor>

Namespace
Akka.TestKit
Assembly
Akka.TestKit.dll

This special ActorRef is exclusively for use during unit testing in a single-threaded environment. Therefore, it overrides the dispatcher to CallingThreadDispatcher and sets the receiveTimeout to None. Otherwise, it acts just like a normal ActorRef. You may retrieve a reference to the underlying actor to test internal logic. A TestActorRef<TActor> can be implicitly casted to an Akka.Actor.IActorRef or you can get the actual Akka.Actor.IActorRef from the Ref property.

public class TestActorRef<TActor> : TestActorRefBase<TActor>, ICanTell, IEquatable<IActorRef>, IInternalActorRef, IActorRef, IComparable<IActorRef>, ISurrogated, IComparable, IActorRefScope where TActor : ActorBase

Type Parameters

TActor

The type of actor

Inheritance
TestActorRef<TActor>
Implements
ICanTell
IEquatable<IActorRef>
IInternalActorRef
IActorRef
IComparable<IActorRef>
ISurrogated
IActorRefScope
Inherited Members

Constructors

TestActorRef(ActorSystem, Props, IActorRef, string)

Initializes a new instance of the TestActorRef<TActor> class.

public TestActorRef(ActorSystem system, Props actorProps, IActorRef supervisor = null, string name = null)

Parameters

system ActorSystem

The system.

actorProps Props

The actor props.

supervisor IActorRef

Optional: The supervisor.

name string

Optional: The name.

Operators

operator ==(IActorRef, TestActorRef<TActor>)

Compares a specified Akka.Actor.IActorRef to an TestActorRef<TActor> for equality.

public static bool operator ==(IActorRef actorRef, TestActorRef<TActor> testActorRef)

Parameters

actorRef IActorRef

The actor used for comparison

testActorRef TestActorRef<TActor>

The test actor used for comparison

Returns

bool

true if both actors are equal; otherwise false

operator ==(TestActorRef<TActor>, IActorRef)

Compares a specified TestActorRef<TActor> to an Akka.Actor.IActorRef for equality.

public static bool operator ==(TestActorRef<TActor> testActorRef, IActorRef actorRef)

Parameters

testActorRef TestActorRef<TActor>

The test actor used for comparison

actorRef IActorRef

The actor used for comparison

Returns

bool

true if both actors are equal; otherwise false

operator !=(IActorRef, TestActorRef<TActor>)

Compares a specified Akka.Actor.IActorRef to an TestActorRef<TActor> for inequality.

public static bool operator !=(IActorRef actorRef, TestActorRef<TActor> testActorRef)

Parameters

actorRef IActorRef

The actor used for comparison

testActorRef TestActorRef<TActor>

The test actor used for comparison

Returns

bool

true if both actors are not equal; otherwise false

operator !=(TestActorRef<TActor>, IActorRef)

Compares a specified TestActorRef<TActor> to an Akka.Actor.IActorRef for inequality.

public static bool operator !=(TestActorRef<TActor> testActorRef, IActorRef actorRef)

Parameters

testActorRef TestActorRef<TActor>

The test actor used for comparison

actorRef IActorRef

The actor used for comparison

Returns

bool

true if both actors are not equal; otherwise false