@@ -27,83 +27,45 @@ public void CommandNotInitialized()
2727 [ TestMethod ]
2828 public void EmptyCommand ( )
2929 {
30- using var connection = new Simulation ( ) . CreateDbConnection ( ) ;
31- connection . Open ( ) ;
32-
33- using var command = connection . CreateCommand ( "" ) ;
34-
35- var x = Throws < InvalidOperationException > ( command . ExecuteReader ) ;
30+ var x = Throws < InvalidOperationException > ( new Simulation ( ) . CreateCommand ( "" ) . ExecuteReader ) ;
3631 AreEqual ( "ExecuteReader: CommandText property has not been initialized" , x . Message ) ;
3732 }
3833
3934 [ TestMethod ]
4035 public void SpaceCommand ( )
4136 {
42- using var connection = new Simulation ( ) . CreateDbConnection ( ) ;
43- connection . Open ( ) ;
44-
45- using var command = connection . CreateCommand ( " " ) ;
46- using var reader = command . ExecuteReader ( ) ;
47-
48- IsFalse ( reader . Read ( ) ) ;
37+ IsFalse ( new Simulation ( ) . ExecuteReader ( " " ) . Read ( ) ) ;
4938 }
5039
5140 [ TestMethod ]
5241 public void IncompleteSingleLineCommentCommand ( )
5342 {
54- using var connection = new Simulation ( ) . CreateDbConnection ( ) ;
55- connection . Open ( ) ;
56-
57- using var command = connection . CreateCommand ( "-" ) ;
58- _ = Throws < DbException > ( command . ExecuteReader ) ;
59- }
60-
61- [ TestMethod ]
62- public void SingleLineEmptyCommentCommand ( )
63- {
64- using var connection = new Simulation ( ) . CreateDbConnection ( ) ;
65- connection . Open ( ) ;
66-
67- using var command = connection . CreateCommand ( "--" ) ;
68- using var reader = command . ExecuteReader ( ) ;
69-
70- IsFalse ( reader . Read ( ) ) ;
43+ _ = Throws < DbException > ( ( ) => new Simulation ( ) . ExecuteReader ( "-" ) ) ;
7144 }
7245
7346 [ TestMethod ]
74- public void SingleLineCommentCommand ( )
47+ [ DataRow ( "--" ) ]
48+ [ DataRow ( "--Test" ) ]
49+ [ DataRow ( "--Test \n " ) ]
50+ [ DataRow ( "--Test \r " ) ]
51+ [ DataRow ( "--Test \r \n " ) ]
52+ [ DataRow ( "--Test\n " ) ]
53+ [ DataRow ( "--Test\r " ) ]
54+ [ DataRow ( "--Test\r \n " ) ]
55+ public void LineComment ( string comment )
7556 {
76- using var connection = new Simulation ( ) . CreateDbConnection ( ) ;
77- connection . Open ( ) ;
78-
79- using var command = connection . CreateCommand ( "-- Test" ) ;
80- using var reader = command . ExecuteReader ( ) ;
81-
82- IsFalse ( reader . Read ( ) ) ;
83- }
84-
85- [ TestMethod ]
86- public void SingleLineCommentWithNewlineCommand ( )
87- {
88- using var connection = new Simulation ( ) . CreateDbConnection ( ) ;
89- connection . Open ( ) ;
90-
91- using var command = connection . CreateCommand ( "-- Test\n " ) ;
92- using var reader = command . ExecuteReader ( ) ;
93-
94- IsFalse ( reader . Read ( ) ) ;
95- }
96-
97- [ TestMethod ]
98- public void SingleLineCommentWithCarriageReturnCommand ( )
99- {
100- using var connection = new Simulation ( ) . CreateDbConnection ( ) ;
101- connection . Open ( ) ;
102-
103- using var command = connection . CreateCommand ( "-- Test\r " ) ;
104- using var reader = command . ExecuteReader ( ) ;
105-
106- IsFalse ( reader . Read ( ) ) ;
57+ IsNull ( new Simulation ( ) . ExecuteScalar ( $ "{ comment } ") ) ;
58+ AreEqual ( 1 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 1 { comment } ") ) ;
59+ AreEqual ( 2 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 2{ comment } ") ) ;
60+ AreEqual ( 3 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 3\n { comment } ") ) ;
61+ AreEqual ( 4 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 4 \n { comment } ") ) ;
62+ AreEqual ( 5 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 5\r { comment } ") ) ;
63+ AreEqual ( 6 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 6 \r { comment } ") ) ;
64+ AreEqual ( 7 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 7\r \n { comment } ") ) ;
65+ AreEqual ( 8 , new Simulation ( ) . ExecuteScalar < int > ( $ "select 8 \r \n { comment } ") ) ;
66+ AreEqual ( 9 , new Simulation ( ) . ExecuteScalar < int > ( $ "{ comment } \n select 9") ) ;
67+ AreEqual ( 10 , new Simulation ( ) . ExecuteScalar < int > ( $ "{ comment } \r select 10") ) ;
68+ AreEqual ( 11 , new Simulation ( ) . ExecuteScalar < int > ( $ "{ comment } \r \n select 11") ) ;
10769 }
10870
10971 [ TestMethod ]
0 commit comments