Skip to content

Commit 354e154

Browse files
committed
Add DropTableAsync test for #1143
1 parent 2d90d46 commit 354e154

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/SQLite.Tests/DropTableTest.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Text;
77
using SQLite;
8+
using System.Threading.Tasks;
89

910
#if NETFX_CORE
1011
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
@@ -37,6 +38,14 @@ public TestDb () : base(TestPath.GetTempFileName ())
3738
}
3839
}
3940

41+
public class TestDbAsync : SQLiteAsyncConnection
42+
{
43+
public TestDbAsync () : base(TestPath.GetTempFileName ())
44+
{
45+
Trace = true;
46+
}
47+
}
48+
4049
[Test]
4150
public void CreateInsertDrop ()
4251
{
@@ -57,5 +66,31 @@ public void CreateInsertDrop ()
5766

5867
ExceptionAssert.Throws<SQLiteException>(() => db.Table<Product> ().Count ());
5968
}
69+
70+
[Test]
71+
public async Task CreateInsertDropAsync ()
72+
{
73+
var db = new TestDbAsync ();
74+
75+
await db.CreateTableAsync<Product> ();
76+
77+
await db.InsertAsync (new Product {
78+
Name = "Hello",
79+
Price = 16,
80+
});
81+
82+
var n = await db.Table<Product> ().CountAsync ();
83+
84+
Assert.AreEqual (1, n);
85+
86+
await db.DropTableAsync<Product> ();
87+
88+
try {
89+
await db.Table<Product> ().CountAsync ();
90+
Assert.Fail ("Should have thrown");
91+
} catch (SQLiteException) {
92+
// Expected
93+
}
94+
}
6095
}
6196
}

0 commit comments

Comments
 (0)