forked from praeclarum/sqlite-net
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDateTimeOffsetTest.cs
More file actions
78 lines (63 loc) · 1.6 KB
/
DateTimeOffsetTest.cs
File metadata and controls
78 lines (63 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
#if NETFX_CORE
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using SetUp = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestInitializeAttribute;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
#else
using NUnit.Framework;
#endif
namespace SQLite.Tests
{
[TestFixture]
public class DateTimeOffsetTest
{
class TestObj
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
public DateTimeOffset ModifiedTime { get; set; }
}
[Test]
public void AsTicks ()
{
var db = new TestDb ();
TestDateTimeOffset (db);
}
[Test]
public void AsyncAsTicks ()
{
var db = new SQLiteAsyncConnection (TestPath.GetTempFileName ());
TestAsyncDateTimeOffset (db);
}
void TestAsyncDateTimeOffset (SQLiteAsyncConnection db)
{
db.CreateTableAsync<TestObj> ().Wait ();
TestObj o, o2;
//
// Ticks
//
o = new TestObj {
ModifiedTime = new DateTimeOffset (2012, 1, 14, 3, 2, 1, TimeSpan.Zero),
};
db.InsertAsync (o).Wait ();
o2 = db.GetAsync<TestObj> (o.Id).Result;
Assert.AreEqual (o.ModifiedTime, o2.ModifiedTime);
}
void TestDateTimeOffset (TestDb db)
{
db.CreateTable<TestObj> ();
TestObj o, o2;
//
// Ticks
//
o = new TestObj {
ModifiedTime = new DateTimeOffset (2012, 1, 14, 3, 2, 1, TimeSpan.Zero),
};
db.Insert (o);
o2 = db.Get<TestObj> (o.Id);
Assert.AreEqual (o.ModifiedTime, o2.ModifiedTime);
}
}
}