diff --git a/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs b/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs index d2054d18c..6ff25efc6 100644 --- a/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs +++ b/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs @@ -36,7 +36,7 @@ namespace Squidex.Infrastructure.Commands public T GetSnapshot(long version) { - if (version <= EtagVersion.Any) + if (version == EtagVersion.Any || version == EtagVersion.Auto) { return Snapshot; } diff --git a/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentLoaderTests.cs b/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentLoaderTests.cs index bbf6e5eed..0f9c591a6 100644 --- a/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentLoaderTests.cs +++ b/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentLoaderTests.cs @@ -55,7 +55,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries { var content = new ContentEntity { Version = 5 }; - A.CallTo(() => grain.GetStateAsync(10)) + A.CallTo(() => grain.GetStateAsync(EtagVersion.Any)) .Returns(J.Of(content)); await sut.GetAsync(id, EtagVersion.Any); diff --git a/tests/Squidex.Infrastructure.Tests/Commands/LogSnapshotDomainObjectGrainTests.cs b/tests/Squidex.Infrastructure.Tests/Commands/LogSnapshotDomainObjectGrainTests.cs index aecbb6bf8..94f56de94 100644 --- a/tests/Squidex.Infrastructure.Tests/Commands/LogSnapshotDomainObjectGrainTests.cs +++ b/tests/Squidex.Infrastructure.Tests/Commands/LogSnapshotDomainObjectGrainTests.cs @@ -93,6 +93,16 @@ namespace Squidex.Infrastructure.Commands result.Should().BeEquivalentTo(new MyDomainState { Value = 8, Version = 1 }); } + [Fact] + public async Task Should_get_latestet_version_when_requesting_state_with_auto() + { + await SetupUpdatedAsync(); + + var result = sut.GetSnapshot(EtagVersion.Auto); + + result.Should().BeEquivalentTo(new MyDomainState { Value = 8, Version = 1 }); + } + [Fact] public async Task Should_get_empty_version_when_requesting_state_with_empty_version() { @@ -117,7 +127,7 @@ namespace Squidex.Infrastructure.Commands { await SetupUpdatedAsync(); - Assert.Null(sut.GetSnapshot(-3)); + Assert.Null(sut.GetSnapshot(-4)); Assert.Null(sut.GetSnapshot(2)); }