private CosmosSqlSagaStateRepository CreateSut(ISagaDbContext dbContext, CosmosSqlSagaStateRepositoryOptions options = null) { var serializer = new JsonSerializer(); var sut = new CosmosSqlSagaStateRepository(dbContext, serializer, options ?? CosmosSqlSagaStateRepositoryOptions.Default); return(sut); }
public async Task LockAsync_should_return_state_if_lock_expired() { var options = new CosmosSqlSagaStateRepositoryOptions(TimeSpan.Zero); var(dbContext, _) = _fixture.CreateDbContext(); var sut = CreateSut(dbContext, options); var newState = DummyState.New(); var(firstState, firstLockId) = await sut.LockAsync(newState.Id, newState, CancellationToken.None); await Task.Delay(500); var(secondState, secondLockId) = await sut.LockAsync(newState.Id, newState, CancellationToken.None); secondLockId.Should().NotBe(firstLockId); secondState.Should().NotBeNull(); }
public CosmosSqlSagaStateRepository(ISagaDbContext dbContext, ISerializer serializer, CosmosSqlSagaStateRepositoryOptions options) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); _options = options ?? throw new ArgumentNullException(nameof(options)); }