Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ stresults.htm

docs/.vitepress/dist
docs/.vitepress/cache
docs/public/freight-shipping-tutorial.zip

src/CommandLineRunner/Internal/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,48 @@ public async Task fetch_for_writing_by_tags_works_for_pure_boundary_aggregate()
boundary.Events.Count.ShouldBe(2);
}
}

// Same setup as the sibling fixture but without overriding StreamIdentity,
// covering the default AsGuid path.
[Collection("OneOffs")]
public class dcb_boundary_aggregate_default_stream_identity_tests: OneOffConfigurationsContext, IAsyncLifetime
{
private void ConfigureStore()
{
StoreOptions(opts =>
{
opts.Events.AddEventType<Enrolled>();
opts.Events.AddEventType<ProgressRecorded>();

opts.Events.RegisterTagType<EnrolleeId>("enrollee").ForAggregate<SubscriptionState>();
opts.Events.RegisterTagType<ProgramId>("program").ForAggregate<SubscriptionState>();
});
}

public Task InitializeAsync()
{
ConfigureStore();
return Task.CompletedTask;
}

public Task DisposeAsync() => Task.CompletedTask;

[Fact]
public async Task fetch_for_writing_by_tags_works_with_default_guid_stream_identity()
{
var enrolleeId = new EnrolleeId(Guid.NewGuid());

var enrolled = theSession.Events.BuildEvent(new Enrolled("Bob"));
enrolled.WithTag(enrolleeId);
theSession.Events.Append(Guid.NewGuid(), enrolled);

await theSession.SaveChangesAsync();

await using var session = theStore.LightweightSession();
var query = new EventTagQuery().Or<EnrolleeId>(enrolleeId);
var boundary = await session.Events.FetchForWritingByTags<SubscriptionState>(query);

boundary.Aggregate.ShouldNotBeNull();
boundary.Aggregate!.EnrollmentCount.ShouldBe(1);
}
}
8 changes: 7 additions & 1 deletion src/Marten/Events/EventGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ internal EventGraph(StoreOptions options)
// there is no Id member
if (idType == null)
{
if (StreamIdentity == StreamIdentity.AsGuid)
// [BoundaryAggregate] SG emits TId=string (see jasperfx#324); match
// it here so the dispatcher lookup hits regardless of StreamIdentity.
if (typeof(TDoc).IsDefined(typeof(BoundaryAggregateAttribute), inherit: false))
{
idType = typeof(string);
}
else if (StreamIdentity == StreamIdentity.AsGuid)
{
idType = typeof(Guid);
}
Expand Down
Loading