3
3
4
4
using System . Linq ;
5
5
using System . Text ;
6
- using MySql . Data . MySqlClient ;
7
6
using NUnit . Framework ;
8
7
using ServiceStack . DataAnnotations ;
9
8
using ServiceStack . Model ;
@@ -18,77 +17,65 @@ public class StringColumnTests
18
17
[ Test ]
19
18
public void Can_create_primary_key_varchar_with_string_length_255 ( )
20
19
{
21
- using ( var db = OpenDbConnection ( ) )
22
- {
23
- db . CreateTable < TypeWithStringId_255 > ( true ) ;
24
- }
20
+ using var db = OpenDbConnection ( ) ;
21
+ db . CreateTable < TypeWithStringId_255 > ( true ) ;
25
22
}
26
23
27
24
[ Test ]
28
25
public void Can_create_primary_key_varchar_without_setting_string_length ( )
29
26
{
30
- using ( var db = OpenDbConnection ( ) )
31
- {
32
- db . CreateTable < TypeWithStringId > ( true ) ;
33
- }
27
+ using var db = OpenDbConnection ( ) ;
28
+ db . CreateTable < TypeWithStringId > ( true ) ;
34
29
}
35
30
36
31
[ Test ]
37
32
public void Can_create_unique_key_on_varchar_without_setting_string_length ( )
38
33
{
39
- using ( var db = OpenDbConnection ( ) )
40
- {
41
- db . CreateTable < TypeWithUniqeKeyOnVarchar > ( true ) ;
42
- }
34
+ using var db = OpenDbConnection ( ) ;
35
+ db . CreateTable < TypeWithUniqeKeyOnVarchar > ( true ) ;
43
36
}
44
37
45
38
[ Test ]
46
39
public void Can_store_and_retrieve_string_with_8000_characters_from_varchar_field ( )
47
40
{
48
- using ( var db = OpenDbConnection ( ) )
49
- {
50
- db . CreateTable < TypeWithStringId > ( true ) ;
41
+ using var db = OpenDbConnection ( ) ;
42
+ db . CreateTable < TypeWithStringId > ( true ) ;
51
43
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
+ } ;
56
48
57
- Assert . AreEqual ( 8000 , obj . Value . Length ) ;
49
+ Assert . AreEqual ( 8000 , obj . Value . Length ) ;
58
50
59
- db . Save ( obj ) ;
60
- var target = db . SingleById < TypeWithStringId > ( obj . Id ) ;
51
+ db . Save ( obj ) ;
52
+ var target = db . SingleById < TypeWithStringId > ( obj . Id ) ;
61
53
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 ) ;
65
56
}
66
57
67
58
[ Test ]
68
59
public void Can_store_and_retrieve_string_with_8000_characters_from_text_field ( )
69
60
{
70
- using ( var db = OpenDbConnection ( ) )
71
- {
72
- db . CreateTable < TypeWithTextField > ( true ) ;
61
+ using var db = OpenDbConnection ( ) ;
62
+ db . CreateTable < TypeWithTextField > ( true ) ;
73
63
74
- var obj = new TypeWithTextField ( ) {
75
- Value = CreateString ( 8000 )
76
- } ;
64
+ var obj = new TypeWithTextField ( ) {
65
+ Value = CreateString ( 8000 )
66
+ } ;
77
67
78
- Assert . AreEqual ( 8000 , obj . Value . Length ) ;
68
+ Assert . AreEqual ( 8000 , obj . Value . Length ) ;
79
69
80
- db . Save ( obj ) ;
81
- obj . Id = ( int ) db . LastInsertId ( ) ;
70
+ db . Save ( obj ) ;
71
+ obj . Id = ( int ) db . LastInsertId ( ) ;
82
72
83
- var target = db . SingleById < TypeWithTextField > ( obj . Id ) ;
73
+ var target = db . SingleById < TypeWithTextField > ( obj . Id ) ;
84
74
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 ) ;
88
77
}
89
78
90
- #region classes
91
-
92
79
class TypeWithUniqeKeyOnVarchar
93
80
{
94
81
public int Id { get ; set ; }
@@ -146,8 +133,6 @@ class TypeWithStringId_256 : IHasStringId
146
133
public string Value { get ; set ; }
147
134
}
148
135
149
- #endregion
150
-
151
136
private static string CreateString ( int length )
152
137
{
153
138
const string loremIpsum =
0 commit comments