33
44using System . Linq ;
55using System . Text ;
6- using MySql . Data . MySqlClient ;
76using NUnit . Framework ;
87using ServiceStack . DataAnnotations ;
98using ServiceStack . Model ;
@@ -18,77 +17,65 @@ public class StringColumnTests
1817 [ Test ]
1918 public void Can_create_primary_key_varchar_with_string_length_255 ( )
2019 {
21- using ( var db = OpenDbConnection ( ) )
22- {
23- db . CreateTable < TypeWithStringId_255 > ( true ) ;
24- }
20+ using var db = OpenDbConnection ( ) ;
21+ db . CreateTable < TypeWithStringId_255 > ( true ) ;
2522 }
2623
2724 [ Test ]
2825 public void Can_create_primary_key_varchar_without_setting_string_length ( )
2926 {
30- using ( var db = OpenDbConnection ( ) )
31- {
32- db . CreateTable < TypeWithStringId > ( true ) ;
33- }
27+ using var db = OpenDbConnection ( ) ;
28+ db . CreateTable < TypeWithStringId > ( true ) ;
3429 }
3530
3631 [ Test ]
3732 public void Can_create_unique_key_on_varchar_without_setting_string_length ( )
3833 {
39- using ( var db = OpenDbConnection ( ) )
40- {
41- db . CreateTable < TypeWithUniqeKeyOnVarchar > ( true ) ;
42- }
34+ using var db = OpenDbConnection ( ) ;
35+ db . CreateTable < TypeWithUniqeKeyOnVarchar > ( true ) ;
4336 }
4437
4538 [ Test ]
4639 public void Can_store_and_retrieve_string_with_8000_characters_from_varchar_field ( )
4740 {
48- using ( var db = OpenDbConnection ( ) )
49- {
50- db . CreateTable < TypeWithStringId > ( true ) ;
41+ using var db = OpenDbConnection ( ) ;
42+ db . CreateTable < TypeWithStringId > ( true ) ;
5143
52- var obj = new TypeWithStringId {
53- Id = "a" ,
54- Value = CreateString ( 8000 )
55- } ;
44+ var obj = new TypeWithStringId {
45+ Id = "a" ,
46+ Value = CreateString ( 8000 )
47+ } ;
5648
57- Assert . AreEqual ( 8000 , obj . Value . Length ) ;
49+ Assert . AreEqual ( 8000 , obj . Value . Length ) ;
5850
59- db . Save ( obj ) ;
60- var target = db . SingleById < TypeWithStringId > ( obj . Id ) ;
51+ db . Save ( obj ) ;
52+ var target = db . SingleById < TypeWithStringId > ( obj . Id ) ;
6153
62- Assert . AreEqual ( obj . Value , target . Value ) ;
63- Assert . AreEqual ( 8000 , obj . Value . Length ) ;
64- }
54+ Assert . AreEqual ( obj . Value , target . Value ) ;
55+ Assert . AreEqual ( 8000 , obj . Value . Length ) ;
6556 }
6657
6758 [ Test ]
6859 public void Can_store_and_retrieve_string_with_8000_characters_from_text_field ( )
6960 {
70- using ( var db = OpenDbConnection ( ) )
71- {
72- db . CreateTable < TypeWithTextField > ( true ) ;
61+ using var db = OpenDbConnection ( ) ;
62+ db . CreateTable < TypeWithTextField > ( true ) ;
7363
74- var obj = new TypeWithTextField ( ) {
75- Value = CreateString ( 8000 )
76- } ;
64+ var obj = new TypeWithTextField ( ) {
65+ Value = CreateString ( 8000 )
66+ } ;
7767
78- Assert . AreEqual ( 8000 , obj . Value . Length ) ;
68+ Assert . AreEqual ( 8000 , obj . Value . Length ) ;
7969
80- db . Save ( obj ) ;
81- obj . Id = ( int ) db . LastInsertId ( ) ;
70+ db . Save ( obj ) ;
71+ obj . Id = ( int ) db . LastInsertId ( ) ;
8272
83- var target = db . SingleById < TypeWithTextField > ( obj . Id ) ;
73+ var target = db . SingleById < TypeWithTextField > ( obj . Id ) ;
8474
85- Assert . AreEqual ( obj . Value , target . Value ) ;
86- Assert . AreEqual ( 8000 , obj . Value . Length ) ;
87- }
75+ Assert . AreEqual ( obj . Value , target . Value ) ;
76+ Assert . AreEqual ( 8000 , obj . Value . Length ) ;
8877 }
8978
90- #region classes
91-
9279 class TypeWithUniqeKeyOnVarchar
9380 {
9481 public int Id { get ; set ; }
@@ -146,8 +133,6 @@ class TypeWithStringId_256 : IHasStringId
146133 public string Value { get ; set ; }
147134 }
148135
149- #endregion
150-
151136 private static string CreateString ( int length )
152137 {
153138 const string loremIpsum =
0 commit comments