forked from koush/sqlite-net
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScalarTest.cs
50 lines (41 loc) · 1.08 KB
/
ScalarTest.cs
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
using System;
using System.Linq;
#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 ScalarTest
{
class TestTable
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public int Two { get; set; }
}
const int Count = 100;
SQLiteConnection CreateDb ()
{
var db = new TestDb ();
db.CreateTable<TestTable> ();
var items = from i in Enumerable.Range (0, Count)
select new TestTable { Two = 2 };
db.InsertAll (items);
Assert.AreEqual (Count, db.Table<TestTable> ().Count ());
return db;
}
[Test]
public void Int32 ()
{
var db = CreateDb ();
var r = db.ExecuteScalar<int> ("SELECT SUM(Two) FROM TestTable");
Assert.AreEqual (Count * 2, r);
}
}
}