Repository: dotnet/efcore
File: test/Microsoft.Data.Sqlite.Tests/SqliteDataReaderTest.cs (C#)

Code before:

            Assert.Equal(2, reader.RecordsAffected);
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements()
    {
        using var connection = new SqliteConnection("Data Source=:memory:");
        connection.Open();

        using (var reader = connection.ExecuteReader(
            @"CREATE TABLE foo(bar TEXT NOT NULL);
              CREATE TABLE xyz(aaa TEXT NOT NULL);
              INSERT INTO foo(bar) VALUES('baz');
              INSERT INTO foo(bar) VALUES('baz2');
              DROP TABLE xyz;"))
        {
            Assert.Equal(2, reader.RecordsAffected);
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements_with_drop_and_create()
    {
        using var connection = new SqliteConnection("Data Source=:memory:");
        connection.Open();

        connection.ExecuteNonQuery("CREATE TABLE foo(bar TEXT NOT NULL);");

        using (var reader = connection.ExecuteReader(
            @"DROP TABLE foo;
              CREATE TABLE foo(bar TEXT NOT NULL);
              CREATE TABLE xyz(aaa TEXT NOT NULL);
              INSERT INTO foo(bar) VALUES('baz');
              INSERT INTO foo(bar) VALUES('baz2');
              DROP TABLE xyz;
              CREATE TABLE xyz(aaa TEXT NOT NULL);"))
        {
            Assert.Equal(2, reader.RecordsAffected);
        }
    }

    [Fact]
    public void GetSchemaTable_works()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            connection.Open();
            connection.ExecuteNonQuery(
                "CREATE TABLE Person (ID INTEGER PRIMARY KEY, FirstName TEXT, LastName TEXT NOT NULL, Code INT UNIQUE);");

Review comment (suggestion):
To be consistent with rest of the file, use `using (var connection = new SqliteConnection("Data Source=:memory:"))`, aka with block.

Code after:

            Assert.Equal(2, reader.RecordsAffected);
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            connection.Open();

            using (var reader = connection.ExecuteReader(
                @"CREATE TABLE foo(bar TEXT NOT NULL);
                  CREATE TABLE xyz(aaa TEXT NOT NULL);
                  INSERT INTO foo(bar) VALUES('baz');
                  INSERT INTO foo(bar) VALUES('baz2');
                  DROP TABLE xyz;"))
            {
                Assert.Equal(2, reader.RecordsAffected);
            }
        }
    }

    [Fact]
    public void RecordsAffected_not_affected_by_DDL_statements_with_drop_and_create()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            connection.Open();

            using (var reader = connection.ExecuteReader(
                @"CREATE TABLE foo(bar TEXT NOT NULL);
                  CREATE TABLE xyz(aaa TEXT NOT NULL);
                  INSERT INTO foo(bar) VALUES('baz');
                  INSERT INTO foo(bar) VALUES('baz2');
                  DROP TABLE xyz;
                  CREATE TABLE xyz(aaa TEXT NOT NULL);"))
            {
                Assert.Equal(2, reader.RecordsAffected);
            }
        }
    }

    [Fact]
    public void GetSchemaTable_works()
    {
        using (var connection = new SqliteConnection("Data Source=:memory:"))
        {
            connection.Open();
            connection.ExecuteNonQuery(