Created
February 14, 2018 11:06
-
-
Save nsanitate/7bda165ab3ee7bb50335fd8002a1453a to your computer and use it in GitHub Desktop.
Simple test on PersistentActor raise timeout exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FakeActor : ReceivePersistentActor | |
{ | |
public override string PersistenceId { get; } = "HashCoded"; | |
public FakeActor() | |
{ | |
Command<FakeRequest>(request => | |
{ | |
Sender.Tell(new FakeResponse(requestId: request.RequestId)); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class FakeActorTest : TestKit | |
{ | |
[Test] | |
public void FakeActor_FakeRequest() | |
{ | |
// Arrange | |
var senderProbe = CreateTestProbe(); | |
var sut = Sys.ActorOf(Props.Create<FakeActor>()); | |
// Act | |
sut.Tell(new FakeRequest(1), senderProbe.Ref); | |
// Assert | |
senderProbe.ExpectMsg<FakeResponse>(r => r.RequestId == 1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FakeRequest | |
{ | |
public FakeRequest(ulong requestId) { RequestId = requestId; } | |
public override string ToString() => $"FakeRequest: {RequestId}"; | |
public ulong RequestId { get; private set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FakeResponse | |
{ | |
public FakeResponse(ulong requestId) { RequestId = requestId; } | |
public override string ToString() => $"FakeResponse: {RequestId}"; | |
public ulong RequestId { get; private set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment