public void raises_concurrency_issue() { var aggregate = new SimpleEventSourcedRoot(); var result = aggregate.Must().HaveVersion(1); result.Should().BeInvalid().WithMessage(ConcurrencyIssue.VersionMismatch(1, 0)); }
public static Result <TAggregate> HaveVersion <TAggregate>(this Must <TAggregate> must, int expected) where TAggregate : AggregateRoot <TAggregate>, new() { Guard.NotNull(must, nameof(must)); Guard.NotNegative(expected, nameof(expected)); int actual = ((dynamic)must.Subject).Version; return(must.Be(actual == expected, ConcurrencyIssue.VersionMismatch(expected, actual))); }