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))); }
private Result <NameSelection> MustBeKnown(string name, string propertyName) => Must.Be( model: this, condition: Names.Contains(name), propertyName: propertyName, message: Message.CandidateNotFound);