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

Code before:

            connection.ExecuteNonQuery("CREATE TABLE Data (Value); INSERT INTO Data VALUES ('test');");

            using (var reader = connection.ExecuteReader("SELECT rowid, Value FROM Data;"))
            {
                var hasData = reader.Read();
                Assert.True(hasData);

                using (var textReader = reader.GetTextReader(1))
                {
                    Assert.IsType<SqliteBlob>(Assert.IsType<StreamReader>(textReader).BaseStream);
                    Assert.Equal("test", textReader.ReadToEnd());
                }
            }
        }
    }

    [Fact]
    public void GetDateTime_works_with_text()
        => GetX_works(
            "SELECT '2014-04-15 10:47:16';",
            r => r.GetDateTime(0),
            new DateTime(2014, 4, 15, 10, 47, 16));

    [Fact]
    public void GetDateTime_works_with_text_Kind()
        => GetX_works(
            "SELECT '2014-04-15 10:47:16';",
            r => r.GetDateTime(0).Kind,
            DateTimeKind.Unspecified);

    [Fact]
    public void GetDateTime_works_with_text_with_tz()
        => GetX_works(
            "SELECT '2014-04-15 10:47:16+03:00';",
            r => r.GetDateTime(0),
            new DateTime(2014, 4, 15, 7, 47, 16));

    [Fact]
    public void GetDateTime_works_with_text_with_tz_Kind()
        => GetX_works(
            "SELECT '2014-04-15 10:47:16+03:00';",
            r => r.GetDateTime(0).Kind,
            DateTimeKind.Utc);

    [Fact]
    public void GetDateTime_works_with_real()
        => GetX_works(
            "SELECT julianday('2013-10-07 08:23:19.120');",
            r => r.GetDateTime(0),
            new DateTime(2013, 10, 7, 8, 23, 19, 120));

Review comment (refactor):
It would be good to simply check both the value (the timestamp) and the Kind in the same test, to make sure everything works as expected for that scenario; it seems like right now we're splitting that into two tests only because the GetX_works utility doesn't support that.

Maybe add a GetX_works overload that accepts an `Action<T>` as the second parameter, so that you can put multiple assertions (or whatever) there?

Code after:
            connection.Open();

            connection.ExecuteNonQuery("CREATE TABLE Data (Value); INSERT INTO Data VALUES ('test');");

            using (var reader = connection.ExecuteReader("SELECT rowid, Value FROM Data;"))
            {
                var hasData = reader.Read();
                Assert.True(hasData);

                using (var textReader = reader.GetTextReader(1))
                {
                    Assert.IsType<SqliteBlob>(Assert.IsType<StreamReader>(textReader).BaseStream);
                    Assert.Equal("test", textReader.ReadToEnd());
                }
            }
        }
    }

    [Fact]
    public void GetDateTime_works_with_text()
        => GetX_works(
            "SELECT '2014-04-15 10:47:16';",
            r => r.GetDateTime(0),
            new DateTime(2014, 4, 15, 10, 47, 16),
            a => Assert.Equal(DateTimeKind.Unspecified, a.Kind));

    [Fact]
    public void GetDateTime_works_with_text_with_offset()
        => GetX_works(
            "SELECT '2014-04-15 10:47:16+03:00';",
            r => r.GetDateTime(0),
            new DateTime(2014, 4, 15, 7, 47, 16),
            a => Assert.Equal(DateTimeKind.Utc, a.Kind));

    [Fact]
    public void GetDateTime_works_with_real()
        => GetX_works(
            "SELECT julianday('2013-10-07 08:23:19.120');",
            r => r.GetDateTime(0),
            new DateTime(2013, 10, 7, 8, 23, 19, 120),
            a => Assert.Equal(DateTimeKind.Unspecified, a.Kind));

    [Fact]
    public void GetDateTime_works_with_integer()
        => GetX_works(
            "SELECT CAST(julianday('2013-10-07 12:00') AS INTEGER);",
            r => r.GetDateTime(0),
            new DateTime(2013, 10, 7, 12, 0, 0),
            a => Assert.Equal(DateTimeKind.Unspecified, a.Kind));

    [Fact]