Exemplo n.º 1
0
        public async Task Query_should_return_data_from_previous_command()
        {
            var connectionString = CreateUniqueConnectionString();

            await InitializeDatabase(connectionString);

            using var sut = new LongLivedDbTransaction(() => new SqliteConnection(connectionString));
            await sut.ExecuteAsync(new InsertRandomText());

            var recordCount = await sut.QueryAsync(new CountTextEntries());

            recordCount.Should().Be(1);
        }
Exemplo n.º 2
0
        public async Task Command_should_not_be_written_if_aborted()
        {
            var connectionString = CreateUniqueConnectionString();

            await InitializeDatabase(connectionString);

            using var sut = new LongLivedDbTransaction(() => new SqliteConnection(connectionString));
            await sut.ExecuteAsync(new InsertRandomText());

            await sut.AbortAsync();

            var recordCount = await _keepConnectionOpen.ExecuteScalarAsync <int>("SELECT COUNT(1) FROM TextEntries");

            recordCount.Should().Be(0);
        }
Exemplo n.º 3
0
        public async Task Completing_more_than_once_should_only_write_once()
        {
            var connectionString = CreateUniqueConnectionString();

            await InitializeDatabase(connectionString);

            using var sut = new LongLivedDbTransaction(() => new SqliteConnection(connectionString));
            await sut.ExecuteAsync(new InsertRandomText());

            await sut.CompleteAsync();

            await sut.CompleteAsync();

            var recordCount = await _keepConnectionOpen.ExecuteScalarAsync <int>("SELECT COUNT(1) FROM TextEntries");

            recordCount.Should().Be(1);
        }