File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 55using System . Linq ;
66using System . Text ;
77using SQLite ;
8+ using System . Threading . Tasks ;
89
910#if NETFX_CORE
1011using 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}
You can’t perform that action at this time.
0 commit comments