5
5
6
6
namespace SideBySide
7
7
{
8
- public class ParameterCollection : IDisposable
9
- {
10
- public ParameterCollection ( )
11
- {
12
- m_command = new MySqlCommand ( ) ;
8
+ public class ParameterCollection : IDisposable
9
+ {
10
+ public ParameterCollection ( )
11
+ {
12
+ m_command = new MySqlCommand ( ) ;
13
13
m_parameterCollection = m_command . Parameters ;
14
14
}
15
15
16
- public void Dispose ( )
17
- {
18
- m_command . Dispose ( ) ;
19
- }
16
+ public void Dispose ( )
17
+ {
18
+ m_command . Dispose ( ) ;
19
+ }
20
20
21
21
[ Theory ]
22
22
[ InlineData ( "Baz" , 0 ) ]
@@ -33,12 +33,12 @@ public void Dispose()
33
33
[ InlineData ( "?Bar" , - 1 ) ]
34
34
[ InlineData ( "" , - 1 ) ]
35
35
public void FindByName ( string parameterName , int position )
36
- {
37
- m_parameterCollection . Add ( new MySqlParameter { ParameterName = "Baz" , Value = 0 } ) ;
36
+ {
37
+ m_parameterCollection . Add ( new MySqlParameter { ParameterName = "Baz" , Value = 0 } ) ;
38
38
m_parameterCollection . Add ( new MySqlParameter { ParameterName = "@Test" , Value = 1 } ) ;
39
39
m_parameterCollection . Add ( new MySqlParameter { ParameterName = "?Foo" , Value = 2 } ) ;
40
- int index = m_parameterCollection . IndexOf ( parameterName ) ;
41
- Assert . Equal ( position , index ) ;
40
+ int index = m_parameterCollection . IndexOf ( parameterName ) ;
41
+ Assert . Equal ( position , index ) ;
42
42
Assert . Equal ( position != - 1 , m_parameterCollection . Contains ( parameterName ) ) ;
43
43
44
44
string expectedParameterName = parameterName ;
@@ -60,7 +60,31 @@ public void FindByName(string parameterName, int position)
60
60
Assert . NotNull ( parameter ) ;
61
61
Assert . Equal ( expectedParameterName , parameter . ParameterName ) ;
62
62
}
63
- }
63
+ }
64
+
65
+ [ Theory ]
66
+ [ InlineData ( "@test" ) ]
67
+ [ InlineData ( "@Test" ) ]
68
+ [ InlineData ( "@tEsT" ) ]
69
+ [ InlineData ( "@TEST" ) ]
70
+ public void FindByNameIgnoringCase ( string parameterName )
71
+ {
72
+ m_parameterCollection . AddWithValue ( "@Test" , 1 ) ;
73
+ Assert . Equal ( 1 , m_parameterCollection . Count ) ;
74
+
75
+ Assert . True ( m_parameterCollection . Contains ( parameterName ) ) ;
76
+ Assert . Equal ( 0 , m_parameterCollection . IndexOf ( parameterName ) ) ;
77
+
78
+ var parameter = m_parameterCollection [ parameterName ] ;
79
+ Assert . Equal ( "@Test" , parameter . ParameterName ) ;
80
+ Assert . Equal ( 1 , parameter . Value ) ;
81
+
82
+ parameter = m_parameterCollection [ 0 ] ;
83
+ Assert . Equal ( "@Test" , parameter . ParameterName ) ;
84
+
85
+ m_parameterCollection . RemoveAt ( parameterName ) ;
86
+ Assert . Equal ( 0 , m_parameterCollection . Count ) ;
87
+ }
64
88
65
89
[ Fact ]
66
90
public void IndexOfNull ( )
@@ -82,17 +106,17 @@ public void Clear()
82
106
}
83
107
84
108
[ Fact ]
85
- public void RemoveAtIndex ( )
86
- {
109
+ public void RemoveAtIndex ( )
110
+ {
87
111
m_parameterCollection . Add ( new MySqlParameter { ParameterName = "@Test1" , Value = 0 } ) ;
88
112
m_parameterCollection . Add ( new MySqlParameter { ParameterName = "@Test2" , Value = 1 } ) ;
89
113
Assert . Equal ( 0 , m_parameterCollection . IndexOf ( "@Test1" ) ) ;
90
114
Assert . Equal ( 1 , m_parameterCollection . IndexOf ( "@Test2" ) ) ;
91
- m_parameterCollection . RemoveAt ( 0 ) ;
92
- Assert . Equal ( 1 , m_parameterCollection . Count ) ;
115
+ m_parameterCollection . RemoveAt ( 0 ) ;
116
+ Assert . Equal ( 1 , m_parameterCollection . Count ) ;
93
117
Assert . Equal ( - 1 , m_parameterCollection . IndexOf ( "@Test1" ) ) ;
94
118
Assert . Equal ( 0 , m_parameterCollection . IndexOf ( "@Test2" ) ) ;
95
- }
119
+ }
96
120
97
121
[ Fact ]
98
122
public void RemoveAtString ( )
@@ -122,8 +146,8 @@ public void SetParameterIndex()
122
146
}
123
147
124
148
[ Fact ]
125
- public void SetParameterString ( )
126
- {
149
+ public void SetParameterString ( )
150
+ {
127
151
m_parameterCollection . Add ( new MySqlParameter { ParameterName = "@Test1" , Value = 0 } ) ;
128
152
m_parameterCollection . Add ( new MySqlParameter { ParameterName = "@Test2" , Value = 1 } ) ;
129
153
Assert . Equal ( 0 , m_parameterCollection . IndexOf ( "@Test1" ) ) ;
0 commit comments