File tree Expand file tree Collapse file tree 5 files changed +41
-9
lines changed
Expand file tree Collapse file tree 5 files changed +41
-9
lines changed Original file line number Diff line number Diff line change @@ -570,9 +570,7 @@ public void TestAsyncTableQueryToFirstAsyncFound ()
570570 Assert . AreEqual ( customer . Email , loaded . Email ) ;
571571 }
572572
573- #if ! NETFX_CORE
574573 [ Test ]
575- [ ExpectedException ( typeof ( AggregateException ) ) ]
576574 public void TestAsyncTableQueryToFirstAsyncMissing ( )
577575 {
578576 var conn = GetConnection ( ) ;
@@ -585,9 +583,8 @@ public void TestAsyncTableQueryToFirstAsyncMissing ()
585583 // query...
586584 var query = conn . Table < Customer > ( ) . Where ( v => v . Id == - 1 ) ;
587585 var task = query . FirstAsync ( ) ;
588- task . Wait ( ) ;
586+ ExceptionAssert . Throws < AggregateException > ( ( ) => task . Wait ( ) ) ;
589587 }
590- #endif
591588
592589 [ Test ]
593590 public void TestAsyncTableQueryToFirstOrDefaultAsyncFound ( )
Original file line number Diff line number Diff line change @@ -37,8 +37,7 @@ public TestDb () : base(TestPath.GetTempFileName ())
3737 }
3838 }
3939
40- #if ! NETFX_CORE
41- [ Test , ExpectedException ( typeof ( SQLiteException ) ) ]
40+ [ Test ]
4241 public void CreateInsertDrop ( )
4342 {
4443 var db = new TestDb ( ) ;
@@ -56,8 +55,7 @@ public void CreateInsertDrop ()
5655
5756 db . DropTable < Product > ( ) ;
5857
59- db . Table < Product > ( ) . Count ( ) ; // Should throw
58+ ExceptionAssert . Throws < SQLiteException > ( ( ) => db . Table < Product > ( ) . Count ( ) ) ;
6059 }
61- #endif
6260 }
6361}
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using System . Threading . Tasks ;
6+
7+ #if NETFX_CORE
8+ using Microsoft . VisualStudio . TestPlatform . UnitTestFramework ;
9+ #else
10+ using NUnit . Framework ;
11+ #endif
12+
13+ namespace SQLite . Tests
14+ {
15+ public class ExceptionAssert
16+ {
17+ public static T Throws < T > ( Action action ) where T : Exception
18+ {
19+ try
20+ {
21+ action ( ) ;
22+ }
23+ catch ( T ex )
24+ {
25+ return ex ;
26+ }
27+
28+ Assert . Fail ( "Expected exception of type {0}." , typeof ( T ) ) ;
29+
30+ return null ;
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change 3838 <Compile Include =" BooleanTest.cs" />
3939 <Compile Include =" ..\src\SQLite.cs" />
4040 <Compile Include =" ByteArrayTest.cs" />
41+ <Compile Include =" ExceptionAssert.cs" />
4142 <Compile Include =" InsertTest.cs" />
4243 <Compile Include =" CreateTableTest.cs" />
4344 <Compile Include =" GuidTests.cs" />
5859 </Compile >
5960 <Compile Include =" MappingTest.cs" />
6061 </ItemGroup >
61- </Project >
62+ </Project >
Original file line number Diff line number Diff line change 142142 <Compile Include =" ..\DropTableTest.cs" >
143143 <Link >DropTableTest.cs</Link >
144144 </Compile >
145+ <Compile Include =" ..\ExceptionAssert.cs" >
146+ <Link >ExceptionAssert.cs</Link >
147+ </Compile >
145148 <Compile Include =" ..\GuidTests.cs" >
146149 <Link >GuidTests.cs</Link >
147150 </Compile >
You can’t perform that action at this time.
0 commit comments