forked from JasperFx/marten
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JasperFx#3078 Providing a version for aggregating that is too high sh…
…ould aggregate to null
- Loading branch information
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Marten; | ||
using Marten.Testing.Harness; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace EventSourcingTests.Bugs; | ||
|
||
public class Bug_3078_providing_version | ||
{ | ||
[Fact] | ||
public async Task too_high_should_aggregate_to_null() | ||
{ | ||
// Given | ||
var streamId = Guid.NewGuid(); | ||
var options = new StoreOptions(); | ||
options.Connection(ConnectionSource.ConnectionString); | ||
options.Projections.LiveStreamAggregation<PolledAggregate>(); | ||
|
||
// When | ||
var store = new DocumentStore(options); | ||
var session = store.LightweightSession(); | ||
session.Events.Append(streamId, new PollingShouldFail(streamId)); | ||
await session.SaveChangesAsync(); | ||
|
||
// Then | ||
var aggregate = await session.Events.AggregateStreamAsync<PolledAggregate>(streamId, 2); | ||
aggregate.ShouldBeNull(); | ||
} | ||
|
||
[Fact] | ||
public async Task exactly_right_should_aggregate_just_fine() | ||
{ | ||
// Given | ||
var streamId = Guid.NewGuid(); | ||
var options = new StoreOptions(); | ||
options.Connection(ConnectionSource.ConnectionString); | ||
options.Projections.LiveStreamAggregation<PolledAggregate>(); | ||
|
||
// When | ||
var store = new DocumentStore(options); | ||
var session = store.LightweightSession(); | ||
session.Events.Append(streamId, new PollingShouldFail(streamId), new PollingShouldNotFail()); | ||
await session.SaveChangesAsync(); | ||
|
||
// Then | ||
var aggregate = await session.Events.AggregateStreamAsync<PolledAggregate>(streamId, 2); | ||
aggregate.ShouldNotBeNull(); | ||
} | ||
} | ||
|
||
public record PollingShouldFail(Guid AggregateId); | ||
|
||
public record PollingShouldNotFail(); | ||
|
||
public record PolledAggregate(Guid Id) | ||
{ | ||
public static PolledAggregate Create(PollingShouldFail @event) => new(@event.AggregateId); | ||
|
||
public PolledAggregate Apply(PollingShouldNotFail _) => this; | ||
} |
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