Table of Contents

Class TestProbe

Namespace
Akka.TestKit
Assembly
Akka.TestKit.dll

TestKit-based probe which allows sending, reception and reply. Use CreateTestProbe(string) inside your test to create new instances.

public class TestProbe : TestKitBase, IActorRefFactory, INoImplicitSender, IInternalActorRef, IActorRef, ICanTell, IEquatable<IActorRef>, IComparable<IActorRef>, ISurrogated, IComparable, IActorRefScope
Inheritance
TestProbe
Implements
IActorRefFactory
IInternalActorRef
IActorRef
ICanTell
IEquatable<IActorRef>
IComparable<IActorRef>
ISurrogated
IActorRefScope
Inherited Members

Constructors

TestProbe(ActorSystem, ITestKitAssertions, string)

TBD

public TestProbe(ActorSystem system, ITestKitAssertions assertions, string testProbeName = null)

Parameters

system ActorSystem

TBD

assertions ITestKitAssertions

TBD

testProbeName string

TBD

Properties

Ref

Gets the reference of this probe.

public IActorRef Ref { get; }

Property Value

IActorRef

Sender

Gets the sender of the last message

public IActorRef Sender { get; }

Property Value

IActorRef

Methods

ChildActorOfAsync<T>(SupervisorStrategy, CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public Task<IActorRef> ChildActorOfAsync<T>(SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default) where T : ActorBase

Parameters

supervisorStrategy SupervisorStrategy
cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

Task<IActorRef>

Type Parameters

T

ChildActorOfAsync<T>(string, SupervisorStrategy, CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public Task<IActorRef> ChildActorOfAsync<T>(string name, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default) where T : ActorBase

Parameters

name string
supervisorStrategy SupervisorStrategy
cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

Task<IActorRef>

Type Parameters

T

ChildActorOfAsync<T>(string, CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public Task<IActorRef> ChildActorOfAsync<T>(string name, CancellationToken cancellationToken = default) where T : ActorBase

Parameters

name string
cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

Task<IActorRef>

Type Parameters

T

ChildActorOfAsync<T>(CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public Task<IActorRef> ChildActorOfAsync<T>(CancellationToken cancellationToken = default) where T : ActorBase

Parameters

cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

Task<IActorRef>

Type Parameters

T

ChildActorOf<T>(SupervisorStrategy, CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public IActorRef ChildActorOf<T>(SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default) where T : ActorBase

Parameters

supervisorStrategy SupervisorStrategy
cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

IActorRef

Type Parameters

T

ChildActorOf<T>(string, SupervisorStrategy, CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public IActorRef ChildActorOf<T>(string name, SupervisorStrategy supervisorStrategy, CancellationToken cancellationToken = default) where T : ActorBase

Parameters

name string
supervisorStrategy SupervisorStrategy
cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

IActorRef

Type Parameters

T

ChildActorOf<T>(string, CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public IActorRef ChildActorOf<T>(string name, CancellationToken cancellationToken = default) where T : ActorBase

Parameters

name string
cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

IActorRef

Type Parameters

T

ChildActorOf<T>(CancellationToken)

Spawns an actor as a child of this test actor, and returns the child's ActorRef.

public IActorRef ChildActorOf<T>(CancellationToken cancellationToken = default) where T : ActorBase

Parameters

cancellationToken CancellationToken

CancellationToken to cancel the operation

Returns

IActorRef

Type Parameters

T

CompareTo(object)

public int CompareTo(object obj)

Parameters

obj object

Returns

int

CreateTestProbe(string)

N/A

[Obsolete("Cannot create a TestProbe from a TestProbe", true)]
public override TestProbe CreateTestProbe(string name = null)

Parameters

name string

N/A

Returns

TestProbe

N/A

Exceptions

NotSupportedException

This exception is thrown since a TestProbe cannot be created from a TestProbe.

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Forward(IActorRef)

Forwards the last received message to the specified actor as if the LastMessage was sent directly to the actor in the first place.

public void Forward(IActorRef actor)

Parameters

actor IActorRef

The actor to forward to.

Forward(IActorRef, object)

Forwards a message to the specified actor. As sender the sender of the last message is used.

public void Forward(IActorRef actor, object message)

Parameters

actor IActorRef

The actor to forward to.

message object

The message.

GetHashCode()

public override int GetHashCode()

Returns

int

Reply(object)

Send message to the sender of the last received message.

public void Reply(object message)

Parameters

message object

The message.

Send(IActorRef, object)

Send message to an actor while using the probe as the sender. Replies will be available for inspection with all of TestKit's assertion methods.

public void Send(IActorRef actor, object message)

Parameters

actor IActorRef

The actor.

message object

The message.

SendSystemMessage(ISystemMessage)

Sends a system message to the test probe

public void SendSystemMessage(ISystemMessage message)

Parameters

message ISystemMessage

The message to send

SendSystemMessage(ISystemMessage, IActorRef)

Sends a system message to the test probe

public void SendSystemMessage(ISystemMessage message, IActorRef sender)

Parameters

message ISystemMessage

The message to send

sender IActorRef

NOT USED.

ToString()

public override string ToString()

Returns

string