1- using Microsoft . VisualStudio . TestTools . UnitTesting ;
2- using System . Data . Common ;
1+ using System . Data . Common ;
32
43namespace SqlServerSimulator ;
54
65[ TestClass ]
76public class InsertTests
87{
98 [ TestMethod ]
10- [ ExpectedException ( typeof ( DbException ) , AllowDerivedTypes = true ) ]
11- public void InsertRequiresTableToExist ( ) => new Simulation ( )
9+ public void InsertRequiresTableToExist ( ) => Assert . Throws < DbException > ( ( ) => new Simulation ( )
1210 . CreateOpenConnection ( )
1311 . CreateCommand ( "insert t ( v ) values ( 1 )" )
14- . ExecuteNonQuery ( ) ;
12+ . ExecuteNonQuery ( )
13+ ) ;
1514
1615 [ TestMethod ]
1716 public void InsertWithoutColumnNames ( )
@@ -36,14 +35,11 @@ public void InsertParameterized()
3635 }
3736
3837 [ TestMethod ]
39- [ ExpectedException ( typeof ( DbException ) , AllowDerivedTypes = true ) ]
40- public void InsertParameterizedNameMismatch ( )
41- {
42- _ = new Simulation ( )
43- . CreateOpenConnection ( )
44- . CreateCommand ( "create table t ( v int );insert t values ( @p0 )" , ( "p1" , 1 ) )
45- . ExecuteNonQuery ( ) ;
46- }
38+ public void InsertParameterizedNameMismatch ( ) => Assert . Throws < DbException > ( ( ) => new Simulation ( )
39+ . CreateOpenConnection ( )
40+ . CreateCommand ( "create table t ( v int );insert t values ( @p0 )" , ( "p1" , 1 ) )
41+ . ExecuteNonQuery ( )
42+ ) ;
4743
4844 [ TestMethod ]
4945 public void InsertWithoutColumnNamesCaseInsensitive ( )
@@ -79,14 +75,9 @@ public void InsertWithColumnNamesCaseInsensitive()
7975 }
8076
8177 [ TestMethod ]
82- [ ExpectedException ( typeof ( DbException ) , AllowDerivedTypes = true ) ]
83- public void InsertRequiresValidColumnNames ( )
84- {
85- var result = new Simulation ( )
86- . CreateOpenConnection ( )
87- . CreateCommand ( "create table t ( v int );insert t ( x ) values ( 1 )" )
88- . ExecuteNonQuery ( ) ;
89-
90- Assert . AreEqual ( 1 , result ) ;
91- }
78+ public void InsertRequiresValidColumnNames ( ) => Assert . Throws < DbException > ( ( ) => new Simulation ( )
79+ . CreateOpenConnection ( )
80+ . CreateCommand ( "create table t ( v int );insert t ( x ) values ( 1 )" )
81+ . ExecuteNonQuery ( )
82+ ) ;
9283}
0 commit comments