Skip to content

Commit

Permalink
Add DropTableAsync test for praeclarum#1143
Browse files Browse the repository at this point in the history
  • Loading branch information
praeclarum committed Nov 28, 2022
1 parent 2d90d46 commit 354e154
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/SQLite.Tests/DropTableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using SQLite;
using System.Threading.Tasks;

#if NETFX_CORE
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
Expand Down Expand Up @@ -37,6 +38,14 @@ public TestDb () : base(TestPath.GetTempFileName ())
}
}

public class TestDbAsync : SQLiteAsyncConnection
{
public TestDbAsync () : base(TestPath.GetTempFileName ())
{
Trace = true;
}
}

[Test]
public void CreateInsertDrop ()
{
Expand All @@ -57,5 +66,31 @@ public void CreateInsertDrop ()

ExceptionAssert.Throws<SQLiteException>(() => db.Table<Product> ().Count ());
}

[Test]
public async Task CreateInsertDropAsync ()
{
var db = new TestDbAsync ();

await db.CreateTableAsync<Product> ();

await db.InsertAsync (new Product {
Name = "Hello",
Price = 16,
});

var n = await db.Table<Product> ().CountAsync ();

Assert.AreEqual (1, n);

await db.DropTableAsync<Product> ();

try {
await db.Table<Product> ().CountAsync ();
Assert.Fail ("Should have thrown");
} catch (SQLiteException) {
// Expected
}
}
}
}

0 comments on commit 354e154

Please sign in to comment.