-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathDropTableTest.cs
61 lines (49 loc) · 1.24 KB
/
DropTableTest.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
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SQLite;
#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 DropTableTest
{
public class Product
{
[AutoIncrement, PrimaryKey]
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
public class TestDb : SQLiteConnection
{
public TestDb () : base(TestPath.GetTempFileName ())
{
Trace = true;
}
}
[Test]
public void CreateInsertDrop ()
{
var db = new TestDb ();
db.CreateTable<Product> ();
db.Insert (new Product {
Name = "Hello",
Price = 16,
});
var n = db.Table<Product> ().Count ();
Assert.AreEqual (1, n);
db.DropTable<Product> ();
ExceptionAssert.Throws<SQLiteException>(() => db.Table<Product> ().Count ());
}
}
}