I started off doing something like this:
interface IDomainEvent(Id,AggregateId,AggregateVersion)
But I'm now seeing this is a bit silly as "AggregateId" and "AggregateVersion" are not really a business-level concern -- looking at my Aggregates, the Aggregate Id will *naturally* be one of the properties of the Event (e.g. PersonId, AccountId). I guess another way of saying it is that, by looking at any Domain event, it's "source stream" can be determined by looking at the values of its properties.
So it feels like these properties might fit better in metadata.
Also, it's entirely possible that some events do correspond to an aggregate and don't change state -- so version isn't as helpful, also some events don't necessarily correspond to an Aggregate directly, so why force these weird properties into domain events.
Using something like GES, the "stream" is set by looking at the Aggregate/Event-sourced-thing we've applied these events to, so they will get saved to the correct stream, and we'll always load them back from the correct stream also.
Or if they don't correspond to an Aggregate, events can be written explicitly into whatever stream is appropriate.
All good so far -- I'll just include that in metadata. Maybe my only property on a domain event base-class/interface is "Id".
Now for tests.
However, after watching Greg's Assert.That(We.Understand) talk -- I feel like it makes sense that a helpful level of test-abstraction is to say:
"With this handler, given these events, when this command/event occurs, expect this series of events (or exception)"
I feel like Aggregates shouldn't be the concern of these kinds of tests -- it's irrelevant which Aggregate(s) these events apply to. I should be able to "refactor" my Aggregates as long as my events and commands stay consistent.
The issue becomes how to provide the "Given()" enumerable of events that have already occurred in such a way that the "FakeEventStore" can identify which stream they belong to.
I can think of three possible solutions:
2) Give the domain events some (non-serialized) way to indicate which stream is their "source" based on their properties (e.g. IDomainEvent { string GetSourceStream(); }, or *groan* an Attribute (C#))
3) Add logic into the "EventBuilder" classes so that they can handle dealing with appropriate metadata -- now the tests are aware of event metadata.
How are other people handling this?