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

ExecuteScalarAsync_works_on_closed_or_opened_connection() private method

        public async Task ExecuteScalarAsync_works_on_closed_or_opened_connection()
        {
            using( var cmd = new SqlCommand( "select count(*) from sys.objects" ) )
            using( var ctx = new SqlStandardCallContext() )
            {
                ISqlConnectionController c = ctx[TestHelper.GetConnectionString()];
                c.Connection.State.Should().Be( ConnectionState.Closed );
                using( c.ExplicitOpen() )
                {
                    c.Connection.State.Should().Be( ConnectionState.Open );
                    ((int)c.ExecuteScalar( cmd )).Should().BeGreaterThan( 0 );
                }
                c.Connection.State.Should().Be( ConnectionState.Closed );
                ((int)await c.ExecuteScalarAsync( cmd )).Should().BeGreaterThan( 0 );
                c.Connection.State.Should().Be( ConnectionState.Closed );
                cmd.CommandText = "select count(*) from sys.objects where name='no-object-here'";
                using( await c.ExplicitOpenAsync() )
                {
                    c.Connection.State.Should().Be( ConnectionState.Open );
                    ((int)await c.ExecuteScalarAsync( cmd )).Should().Be( 0 );
                }
                c.Connection.State.Should().Be( ConnectionState.Closed );
                ((int)await c.ExecuteScalarAsync( cmd )).Should().Be( 0 );
                c.Connection.State.Should().Be( ConnectionState.Closed );
                cmd.CommandText = "select name from sys.tables where name='no-object-here'";
                using( await c.ExplicitOpenAsync() )
                {
                    (await c.ExecuteScalarAsync( cmd )).Should().BeNull();
                }
                c.Connection.State.Should().Be( ConnectionState.Closed );
            }
        }
    }