Ejemplo n.º 1
0
        public async Task Snapshot_SaveRemove_DataIsCommitted( )
        {
            await SqlScripts.InitDbAsync( );

            await using var connection = new MemoryDbConnection( );
            var memoryDatabase = connection.GetMemoryDatabase( );

            memoryDatabase.SaveSnapshot(  );
            var rows            = memoryDatabase.Tables["dbo.application"].Rows;
            var currentRowCount = rows.Count;


            await connection.OpenAsync( );

            var transaction = await connection.BeginTransactionAsync( );

            await connection.ExecuteAsync(_SqlInsertApplication, new { Name = "Name string", User = "******", DefName = "DefName string" }, transaction);

            await connection.ExecuteAsync(_SqlInsertApplication, new { Name = "Name string", User = "******", DefName = "DefName string" }, transaction);

            await transaction.CommitAsync( );

            memoryDatabase.RemoveSnapshot(  );
            var currentRows = memoryDatabase.Tables["dbo.application"].Rows;

            currentRows.Count.Should( ).Be(currentRowCount + 2);
        }
Ejemplo n.º 2
0
        public async Task Transaction_RollbackUpdate_NoDataIsCommitted( )
        {
            await SqlScripts.InitDbAsync( );

            await using var connection = new MemoryDbConnection( );

            await connection.OpenAsync( );

            var transaction = await connection.BeginTransactionAsync( );

            await connection.ExecuteAsync(_SqlUpdateApplication, transaction);

            await transaction.RollbackAsync( );

            var applications = await connection.QueryAsync <ApplicationDto>(_SqlSelectApplication);

            foreach (var application in applications)
            {
                application.Name.Should().Be("Name String");
            }
        }
Ejemplo n.º 3
0
        public async Task Transaction_Rollback_NoDataIsCommitted( )
        {
            await SqlScripts.InitDbAsync( );

            await using var connection = new MemoryDbConnection( );
            var rows            = connection.GetMemoryDatabase( ).Tables["dbo.application"].Rows;
            var currentRowCount = rows.Count;

            await connection.OpenAsync( );

            var transaction = await connection.BeginTransactionAsync( );

            await connection.ExecuteAsync(_SqlInsertApplication, new { Name = "Name string", User = "******", DefName = "DefName string" }, transaction);

            await connection.ExecuteAsync(_SqlInsertApplication, new { Name = "Name string", User = "******", DefName = "DefName string" }, transaction);

            await transaction.RollbackAsync( );

            var currentRows = connection.GetMemoryDatabase( ).Tables["dbo.application"].Rows;

            currentRows.Count.Should( ).Be(currentRowCount);
        }