Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSaveOperationGuardTests.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresSaveOperationGuardTests.cs ---- using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Postgres; /// /// CT-4 (решение владельца 2026-09-04, «как у EF»): контракт «один scope - один поток» защищён /// операционным детектором уровня EF DbContext. Командный страж соединения ловит только /// НАЛОЖИВШИЕСЯ команды; два перемежающихся async-сохранения могли молча перемешать /// pending-состояние ChangeTracking. Детектор ядра общий - одного провайдера достаточно. /// [Collection("Postgres")] public class PostgresSaveOperationGuardTests { private readonly PostgresFixture _fixture; public PostgresSaveOperationGuardTests(PostgresFixture fixture) => _fixture = fixture; [Fact] public async Task ParallelSaves_OnOneScope_AreLoudlyDetected() { var redb = _fixture.Redb; await redb.SyncSchemeAsync(); var t1 = redb.SaveAsync(new RedbObject { name = "guard-1", Props = new SimpleProps { Title = "a" } }); var t2 = redb.SaveAsync(new RedbObject { name = "guard-2", Props = new SimpleProps { Title = "b" } }); var act = async () => await Task.WhenAll(t1, t2); (await act.Should().ThrowAsync( "второе сохранение, вошедшее до завершения первого, обязано быть громким, а не молча перемешивать состояние")) .WithMessage("*SaveAsync*"); } }