public async Task Completing_more_then_once_should_only_write_once() { // arrange var connectionString = $"Data Source={Guid.NewGuid():N};Mode=Memory;Cache=Shared"; await InitializeDatabase(connectionString); var database = new SqliteConnection(connectionString); // act using var sut = new ShortLivedDbTransaction(() => database); await sut.ExecuteAsync(new InsertRandomText()); await sut.CompleteAsync(); await sut.CompleteAsync(); // assert var recordsFound = await _keepConnectionOpen.ExecuteScalarAsync <int>("SELECT COUNT(1) FROM TextEntries"); Assert.Equal(OneRecordShouldBeFound, recordsFound); }
public async Task Completed_data_should_be_avaiable_for_query() { // arrange var connectionString = $"Data Source={Guid.NewGuid():N};Mode=Memory;Cache=Shared"; await InitializeDatabase(connectionString); var database = new SqliteConnection(connectionString); // act using var sut = new ShortLivedDbTransaction(() => database); await sut.ExecuteAsync(new InsertRandomText()); // <-- insert record await sut.CompleteAsync(); var recordCount = await sut.QueryAsync(new CountTextEntries()); // Assert Assert.Equal(OneRecordShouldBeFound, recordCount); }