@@ -57,33 +57,41 @@ public void TearDown()
5757 }
5858 }
5959
60- public static IEnumerable < TestCaseData > Insert_Parameter_Cases ( )
60+ public static IEnumerable < DbType > Insert_Parameter_Types ( )
6161 {
62- yield return new TestCaseData ( 1 ) ;
63- yield return new TestCaseData ( 10 ) ;
64- yield return new TestCaseData ( 100 ) ;
65- yield return new TestCaseData ( 127 ) ;
66- yield return new TestCaseData ( 1000 ) ;
67- yield return new TestCaseData ( 4096 ) ;
68- yield return new TestCaseData ( 4097 ) ;
69- yield return new TestCaseData ( 8192 ) ;
70- yield return new TestCaseData ( 8193 ) ;
71- yield return new TestCaseData ( 10000 ) ;
72- yield return new TestCaseData ( 16384 ) ;
73- yield return new TestCaseData ( 16385 ) ;
74- yield return new TestCaseData ( 100000 ) ;
75- yield return new TestCaseData ( 1000000 ) ;
62+ yield return DbType . AnsiString ;
63+ yield return DbType . String ;
7664 }
7765
78- [ TestCaseSource ( nameof ( Insert_Parameter_Cases ) ) ]
79- public void Insert_Parameter_Dapper ( int count )
66+ public static IEnumerable < int > Insert_Parameter_Counts ( )
67+ {
68+ yield return 1 ;
69+ yield return 10 ;
70+ yield return 100 ;
71+ yield return 127 ;
72+ yield return 1000 ;
73+ yield return 4096 ;
74+ yield return 4097 ;
75+ yield return 8192 ;
76+ yield return 8193 ;
77+ yield return 10000 ;
78+ yield return 16384 ;
79+ yield return 16385 ;
80+ yield return 100000 ;
81+ yield return 1000000 ;
82+ }
83+
84+ [ Test ]
85+ public void Insert_Parameter_Dapper (
86+ [ ValueSource ( nameof ( Insert_Parameter_Types ) ) ] DbType dbType ,
87+ [ ValueSource ( nameof ( Insert_Parameter_Counts ) ) ] int count )
8088 {
8189 var value = new string ( '1' , count ) ;
8290 using ( var connection = GetConnection ( ) )
8391 {
8492 connection . Execute ( "set textsize 1000000" ) ;
8593 var p = new DynamicParameters ( ) ;
86- p . Add ( "@text_field" , value , DbType . String ) ;
94+ p . Add ( "@text_field" , value , dbType ) ;
8795 connection . Execute ( "insert into [dbo].[insert_text_tests] (text_field) values (@text_field)" , p ) ;
8896 var insertedLength = connection . QuerySingle < int > ( "select top 1 len(text_field) from [dbo].[insert_text_tests]" ) ;
8997 Assert . AreEqual ( value . Length , insertedLength ) ;
@@ -92,8 +100,10 @@ public void Insert_Parameter_Dapper(int count)
92100 Insert_Parameter_VerifyResult ( GetConnection , "insert_text_tests" , "text_field" , value ) ;
93101 }
94102
95- [ TestCaseSource ( nameof ( Insert_Parameter_Cases ) ) ]
96- public void Insert_Parameter_With_Date_Dapper ( int count )
103+ [ Test ]
104+ public void Insert_Parameter_With_Date_Dapper (
105+ [ ValueSource ( nameof ( Insert_Parameter_Types ) ) ] DbType dbType ,
106+ [ ValueSource ( nameof ( Insert_Parameter_Counts ) ) ] int count )
97107 {
98108 var value = new string ( '1' , count ) ;
99109 var date = new DateTime ( 2001 , 2 , 3 , 4 , 5 , 6 ) ;
@@ -102,7 +112,7 @@ public void Insert_Parameter_With_Date_Dapper(int count)
102112 {
103113 connection . Execute ( "set textsize 1000000" ) ;
104114 var p = new DynamicParameters ( ) ;
105- p . Add ( "@text_field" , value , DbType . String ) ;
115+ p . Add ( "@text_field" , value , dbType ) ;
106116 p . Add ( "@date_field" , date , DbType . DateTime ) ;
107117 connection . Execute ( "insert into [dbo].[insert_text_date_tests] (text_field, date_field) values (@text_field, @date_field)" , p ) ;
108118 var insertedLength = connection . QuerySingle < int > ( "select top 1 len(text_field) from [dbo].[insert_text_date_tests]" ) ;
0 commit comments