CK.SqlServer.Tests.ISqlConnectionControllerExtensionTests.using_ISqlConnectionController_extension_methods_asynchronous C# (CSharp) Method

using_ISqlConnectionController_extension_methods_asynchronous() private method

        public async Task using_ISqlConnectionController_extension_methods_asynchronous()
        {
            string tableName = "CK.t" + Guid.NewGuid().ToString( "N" );
            var create = new SqlCommand( $"create table {tableName} ( id int, name varchar(10) ); insert into {tableName}(id,name) values (1,'One'), (2,'Two'), (3,'Three');" );
            var scalar = new SqlCommand( $"select name from {tableName} where id=@Id;" );
            scalar.Parameters.AddWithValue( "@Id", 3 );
            var row = new SqlCommand( $"select top 1 id, name from {tableName} order by id;" );
            var reader = new SqlCommand( $"select id, name from {tableName} order by id;" );
            var clean = new SqlCommand( $"drop table {tableName};" );

            using( var ctx = new SqlStandardCallContext( TestHelper.Monitor ) )
            {
                ISqlConnectionController c = ctx[TestHelper.GetConnectionString()];
                c.Connection.State.Should().Be( ConnectionState.Closed );
                await c.ExecuteNonQueryAsync( create );
                (await c.ExecuteScalarAsync( scalar )).Should().Be( "Three" );
                var rowResult = await c.ExecuteSingleRowAsync( row, r => Tuple.Create( r.GetInt32( 0 ), r.GetString( 1 ) ) );
                rowResult.Item1.Should().Be( 1 );
                rowResult.Item2.Should().Be( "One" );
                var readerResult = await c.ExecuteReaderAsync( reader, r => Tuple.Create( r.GetInt32( 0 ), r.GetString( 1 ) ) );
                readerResult.Should().HaveCount( 3 );
                readerResult[0].Item1.Should().Be( 1 );
                readerResult[1].Item2.Should().Be( "Two" );
                readerResult[2].Item2.Should().Be( "Three" );
                await c.ExecuteNonQueryAsync( clean );
            }
        }