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

Code before:
    }

    [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);");
            connection.ExecuteNonQuery("INSERT INTO Person VALUES(101, 'John', 'Dee', 123);");
            connection.ExecuteNonQuery("INSERT INTO Person VALUES(105, 'Jane', 'Doe', 456);");


Review comment (suggestion):
This is not needed (and causes error because same table is created below).

Code after:
    }

    [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(
                "CREATE TABLE Person (ID INTEGER PRIMARY KEY, FirstName TEXT, LastName TEXT NOT NULL, Code INT UNIQUE);");
            connection.ExecuteNonQuery("INSERT INTO Person VALUES(101, 'John', 'Dee', 123);");
            connection.ExecuteNonQuery("INSERT INTO Person VALUES(105, 'Jane', 'Doe', 456);");