diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-02-24 18:31:54 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-02-24 18:31:54 +0300 |
commit | de9d6af30db402c993f776578ae36fe9851fe176 (patch) | |
tree | 6018238a9ce935cbaf7c3301180ec34d56c4d22d | |
parent | 7584a761ba3f16a3eb90fff82940130dfc13b8f3 (diff) |
[Mono.Data.Sqlite] Add test for b78f4f6e5f21edb07d58e012b0339253c593894a
-rw-r--r-- | mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs b/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs index 15339454b82..969346d0fd4 100644 --- a/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs +++ b/mcs/class/Mono.Data.Sqlite/Test/SqliteTests.cs @@ -64,6 +64,38 @@ namespace MonoTests.Mono.Data.Sqlite } [Test] + public void DateTimeConvert_UTC () + { + using (var connection = new SqliteConnection ($"Data Source={_databasePath};DateTimeKind=Utc")) { + connection.Open (); + + using (var cmd = connection.CreateCommand ()) { + cmd.CommandText = "CREATE TABLE OnlyDates (Date1 DATETIME)"; + cmd.CommandType = CommandType.Text; + cmd.ExecuteNonQuery(); + } + + var datetest = DateTime.UtcNow; + + var sqlInsert = "INSERT INTO TestTable (ID, Modified) VALUES (@id, @mod)"; + using (var cmd = connection.CreateCommand ()) { + cmd.CommandText = $"INSERT INTO OnlyDates (Date1) VALUES (@param1);"; + cmd.CommandType = CommandType.Text; + cmd.Parameters.AddWithValue ("@param1", datetest); + cmd.ExecuteNonQuery(); + } + + using (var cmd = connection.CreateCommand ()) { + cmd.CommandText = $"SELECT Date1 FROM OnlyDates;"; + cmd.CommandType = CommandType.Text; + object objRetrieved = cmd.ExecuteScalar (); + var dateRetrieved = Convert.ToDateTime (objRetrieved); + Assert.AreEqual (DateTimeKind.Unspecified, dateRetrieved.Kind); + } + } + } + + [Test] public void DateTimeConvert () { var dateTime = new DateTime (2016, 9, 15, 12, 1, 53); |