@@ -28,128 +28,109 @@ public class OrmLiteCreateTableTests
28
28
[ Test ]
29
29
public void Can_create_table_with_MaxString_and_Custom_MediumText ( )
30
30
{
31
- using ( var db = OpenDbConnection ( ) )
32
- {
33
- db . DropAndCreateTable < MaxStringTest > ( ) ;
34
-
35
- //var sql = db.GetLastSql();
36
- //Assert.That(sql, Is.StringContaining("`MaxText` LONGTEXT NULL"));
37
- //Assert.That(sql, Is.StringContaining("`MediumText` MEDIUMTEXT NULL"));
38
- }
31
+ using var db = OpenDbConnection ( ) ;
32
+ db . DropAndCreateTable < MaxStringTest > ( ) ;
33
+
34
+ //var sql = db.GetLastSql();
35
+ //Assert.That(sql, Is.StringContaining("`MaxText` LONGTEXT NULL"));
36
+ //Assert.That(sql, Is.StringContaining("`MediumText` MEDIUMTEXT NULL"));
39
37
}
40
38
41
39
[ Test ]
42
40
public void Can_create_ModelWithIdOnly_table ( )
43
41
{
44
- using ( var db = OpenDbConnection ( ) )
45
- {
46
- db . CreateTable < ModelWithIdOnly > ( true ) ;
47
- }
42
+ using var db = OpenDbConnection ( ) ;
43
+ db . CreateTable < ModelWithIdOnly > ( true ) ;
48
44
}
49
45
50
46
[ Test ]
51
47
public void Can_create_ModelWithOnlyStringFields_table ( )
52
48
{
53
- using ( var db = OpenDbConnection ( ) )
54
- {
55
- db . CreateTable < ModelWithOnlyStringFields > ( true ) ;
56
- }
49
+ using var db = OpenDbConnection ( ) ;
50
+ db . CreateTable < ModelWithOnlyStringFields > ( true ) ;
57
51
}
58
52
59
53
[ Test ]
60
54
public void Can_create_ModelWithLongIdAndStringFields_table ( )
61
55
{
62
- using ( var db = OpenDbConnection ( ) )
63
- {
64
- db . CreateTable < ModelWithLongIdAndStringFields > ( true ) ;
65
- }
56
+ using var db = OpenDbConnection ( ) ;
57
+ db . CreateTable < ModelWithLongIdAndStringFields > ( true ) ;
66
58
}
67
59
68
60
[ Test ]
69
61
public void Can_create_ModelWithFieldsOfDifferentTypes_table ( )
70
62
{
71
- using ( var db = OpenDbConnection ( ) )
72
- {
73
- db . CreateTable < ModelWithFieldsOfDifferentTypes > ( true ) ;
74
- }
63
+ using var db = OpenDbConnection ( ) ;
64
+ db . CreateTable < ModelWithFieldsOfDifferentTypes > ( true ) ;
75
65
}
76
66
77
67
[ Test ]
78
68
public void Can_preserve_ModelWithIdOnly_table ( )
79
69
{
80
- using ( var db = OpenDbConnection ( ) )
81
- {
82
- db . CreateTable < ModelWithIdOnly > ( true ) ;
70
+ using var db = OpenDbConnection ( ) ;
71
+ db . CreateTable < ModelWithIdOnly > ( true ) ;
83
72
84
- db . Insert ( new ModelWithIdOnly ( 1 ) ) ;
85
- db . Insert ( new ModelWithIdOnly ( 2 ) ) ;
73
+ db . Insert ( new ModelWithIdOnly ( 1 ) ) ;
74
+ db . Insert ( new ModelWithIdOnly ( 2 ) ) ;
86
75
87
- db . CreateTable < ModelWithIdOnly > ( false ) ;
76
+ db . CreateTable < ModelWithIdOnly > ( false ) ;
88
77
89
- var rows = db . Select < ModelWithIdOnly > ( ) ;
78
+ var rows = db . Select < ModelWithIdOnly > ( ) ;
90
79
91
- Assert . That ( rows , Has . Count . EqualTo ( 2 ) ) ;
92
- }
80
+ Assert . That ( rows , Has . Count . EqualTo ( 2 ) ) ;
93
81
}
94
82
95
83
[ Test ]
96
84
public void Can_preserve_ModelWithIdAndName_table ( )
97
85
{
98
- using ( var db = OpenDbConnection ( ) )
99
- {
100
- db . CreateTable < ModelWithIdAndName > ( true ) ;
86
+ using var db = OpenDbConnection ( ) ;
87
+ db . CreateTable < ModelWithIdAndName > ( true ) ;
101
88
102
- db . Insert ( new ModelWithIdAndName ( 1 ) ) ;
103
- db . Insert ( new ModelWithIdAndName ( 2 ) ) ;
89
+ db . Insert ( new ModelWithIdAndName ( 1 ) ) ;
90
+ db . Insert ( new ModelWithIdAndName ( 2 ) ) ;
104
91
105
- db . CreateTable < ModelWithIdAndName > ( false ) ;
92
+ db . CreateTable < ModelWithIdAndName > ( false ) ;
106
93
107
- var rows = db . Select < ModelWithIdAndName > ( ) ;
94
+ var rows = db . Select < ModelWithIdAndName > ( ) ;
108
95
109
- Assert . That ( rows , Has . Count . EqualTo ( 2 ) ) ;
110
- }
96
+ Assert . That ( rows , Has . Count . EqualTo ( 2 ) ) ;
111
97
}
112
98
113
99
[ Test ]
114
100
public void Can_overwrite_ModelWithIdOnly_table ( )
115
101
{
116
- using ( var db = OpenDbConnection ( ) )
117
- {
118
- db . CreateTable < ModelWithIdOnly > ( true ) ;
102
+ using var db = OpenDbConnection ( ) ;
103
+ db . CreateTable < ModelWithIdOnly > ( true ) ;
119
104
120
- db . Insert ( new ModelWithIdOnly ( 1 ) ) ;
121
- db . Insert ( new ModelWithIdOnly ( 2 ) ) ;
105
+ db . Insert ( new ModelWithIdOnly ( 1 ) ) ;
106
+ db . Insert ( new ModelWithIdOnly ( 2 ) ) ;
122
107
123
- db . CreateTable < ModelWithIdOnly > ( true ) ;
108
+ db . CreateTable < ModelWithIdOnly > ( true ) ;
124
109
125
- var rows = db . Select < ModelWithIdOnly > ( ) ;
110
+ var rows = db . Select < ModelWithIdOnly > ( ) ;
126
111
127
- Assert . That ( rows , Has . Count . EqualTo ( 0 ) ) ;
128
- }
112
+ Assert . That ( rows , Has . Count . EqualTo ( 0 ) ) ;
129
113
}
130
114
131
115
[ Test ]
132
116
public void Can_create_multiple_tables ( )
133
117
{
134
- using ( var db = OpenDbConnection ( ) )
135
- {
136
- db . CreateTables ( true , typeof ( ModelWithIdOnly ) , typeof ( ModelWithIdAndName ) ) ;
118
+ using var db = OpenDbConnection ( ) ;
119
+ db . CreateTables ( true , typeof ( ModelWithIdOnly ) , typeof ( ModelWithIdAndName ) ) ;
137
120
138
- db . Insert ( new ModelWithIdOnly ( 1 ) ) ;
139
- db . Insert ( new ModelWithIdOnly ( 2 ) ) ;
121
+ db . Insert ( new ModelWithIdOnly ( 1 ) ) ;
122
+ db . Insert ( new ModelWithIdOnly ( 2 ) ) ;
140
123
141
- db . Insert ( new ModelWithIdAndName ( 1 ) ) ;
142
- db . Insert ( new ModelWithIdAndName ( 2 ) ) ;
124
+ db . Insert ( new ModelWithIdAndName ( 1 ) ) ;
125
+ db . Insert ( new ModelWithIdAndName ( 2 ) ) ;
143
126
144
- var rows1 = db . Select < ModelWithIdOnly > ( ) ;
145
- var rows2 = db . Select < ModelWithIdOnly > ( ) ;
127
+ var rows1 = db . Select < ModelWithIdOnly > ( ) ;
128
+ var rows2 = db . Select < ModelWithIdOnly > ( ) ;
146
129
147
- Assert . That ( rows1 , Has . Count . EqualTo ( 2 ) ) ;
148
- Assert . That ( rows2 , Has . Count . EqualTo ( 2 ) ) ;
149
- }
130
+ Assert . That ( rows1 , Has . Count . EqualTo ( 2 ) ) ;
131
+ Assert . That ( rows2 , Has . Count . EqualTo ( 2 ) ) ;
150
132
}
151
133
152
-
153
134
[ Test ]
154
135
public void Can_create_ModelWithIdAndName_table_with_specified_DefaultStringLength ( )
155
136
{
@@ -159,6 +140,5 @@ public void Can_create_ModelWithIdAndName_table_with_specified_DefaultStringLeng
159
140
Console . WriteLine ( "createTableSql: " + createTableSql ) ;
160
141
Assert . That ( createTableSql . Contains ( "VARCHAR(255)" ) , Is . True ) ;
161
142
}
162
-
163
143
}
164
144
}
0 commit comments