Asserting if a particular event was persisted by a persistent actor #6158
-
I'm trying to implement a basic event-sourced actor in Akka.NET, and I'm stuck on writing a proper test for it. My actor receives a command Currently, my test looks like this: [Fact]
public void CanRegister()
{
var customerId = Guid.NewGuid();
var customer = ActorOf(() => new Customer(customerId));
var invoiceAddress = new Address("Test", "1", "9999 AA", "Test");
customer.Tell(new RegisterCustomer(
customerId,
"FirstName",
"LastName",
"[email protected]",
invoiceAddress,
invoiceAddress,
DateTime.UtcNow));
// Expect event to be persisted.
} I couldn't find a method on the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I'm sure someone that knows for sure can verify this, but I believe the TestKit has its own version of the ActorSystem that is just for testing. My understanding is that the TestKit is designed to test the logic/behaviour of your actor's code, not the underlying code of the persistent layer. The persistent layer has it's own testing included in it's codebase. Out of curiosity, why do you want to test the persistence later in your unit tests? |
Beta Was this translation helpful? Give feedback.
-
As one potential work-around (I'll have to refresh on docs to see if there's a more usable answer,) if your persistence plugin has a Persistence.Query plugin, you could use that alongside the Events-By-PersistenceId command to see what you got. As a more 'general' work-around, I would suggest:
|
Beta Was this translation helpful? Give feedback.
I'm sure someone that knows for sure can verify this, but I believe the TestKit has its own version of the ActorSystem that is just for testing. My understanding is that the TestKit is designed to test the logic/behaviour of your actor's code, not the underlying code of the persistent layer. The persistent layer has it's own testing included in it's codebase.
Out of curiosity, why do you want to test the persistence later in your unit tests?