67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
+
+
+
+
|
if (param2 == "Field3") return -1;
return String.Compare(param1, param2, true);
}
}
internal class TestCases
{
private bool autoClose;
internal Form1 frm;
internal int total;
internal int passed;
internal int failed;
internal TestCases(bool autoExit)
{
this.autoClose = autoExit;
}
internal bool Succeeded()
{
return (failed == 0) && (passed == total);
}
internal void Run(DbConnection cnn)
{
frm = new Form1();
frm.Show();
Type type = cnn.GetType();
frm.WriteLine("\r\nBeginning Test on " + type.ToString());
SQLiteConnection cnn2 = cnn as SQLiteConnection;
if (cnn2 != null)
{
cnn2 = null;
frm.WriteLine("SQLite v" + SQLiteConnection.SQLiteVersion +
" [" + SQLiteConnection.SQLiteSourceId + "]");
}
total++;
try { CreateTable(cnn); frm.WriteLine("SUCCESS - CreateTable"); }
catch (Exception) { frm.WriteLine("FAIL - CreateTable"); }
try { CreateTable(cnn); frm.WriteLine("SUCCESS - CreateTable"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - CreateTable"); failed++; }
total++;
try { DataTypeTest(cnn); frm.WriteLine("SUCCESS - DataType Test"); }
catch (Exception) { frm.WriteLine("FAIL - DataType Test"); }
try { DataTypeTest(cnn); frm.WriteLine("SUCCESS - DataType Test"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - DataType Test"); failed++; }
total++;
try { FullTextTest(cnn); frm.WriteLine("SUCCESS - Full Text Search"); }
catch (Exception) { frm.WriteLine("FAIL - Full Text Search"); }
try { FullTextTest(cnn); frm.WriteLine("SUCCESS - Full Text Search"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - Full Text Search"); failed++; }
total++;
try { KeyInfoTest(cnn); frm.WriteLine("SUCCESS - KeyInfo Fetch"); }
catch (Exception) { frm.WriteLine("FAIL - KeyInfo Fetch"); }
try { KeyInfoTest(cnn); frm.WriteLine("SUCCESS - KeyInfo Fetch"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - KeyInfo Fetch"); failed++; }
total++;
try { InsertTable(cnn); frm.WriteLine("SUCCESS - InsertTable"); }
catch (Exception) { frm.WriteLine("FAIL - InsertTable"); }
try { InsertTable(cnn); frm.WriteLine("SUCCESS - InsertTable"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - InsertTable"); failed++; }
total++;
try { VerifyInsert(cnn); frm.WriteLine("SUCCESS - VerifyInsert"); }
catch (Exception) { frm.WriteLine("FAIL - VerifyInsert"); }
try { VerifyInsert(cnn); frm.WriteLine("SUCCESS - VerifyInsert"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - VerifyInsert"); failed++; }
total++;
try { CoersionTest(cnn); frm.WriteLine("FAIL - CoersionTest"); }
catch (Exception) { frm.WriteLine("SUCCESS - CoersionTest"); }
try { CoersionTest(cnn); frm.WriteLine("FAIL - CoersionTest"); failed++; }
catch (Exception) { frm.WriteLine("SUCCESS - CoersionTest"); passed++; }
total++;
try { ParameterizedInsert(cnn); frm.WriteLine("SUCCESS - ParameterizedInsert"); }
catch (Exception) { frm.WriteLine("FAIL - ParameterizedInsert"); }
try { ParameterizedInsert(cnn); frm.WriteLine("SUCCESS - ParameterizedInsert"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - ParameterizedInsert"); failed++; }
total++;
try { BinaryInsert(cnn); frm.WriteLine("SUCCESS - BinaryInsert"); }
catch (Exception) { frm.WriteLine("FAIL - BinaryInsert"); }
try { BinaryInsert(cnn); frm.WriteLine("SUCCESS - BinaryInsert"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - BinaryInsert"); failed++; }
total++;
try { VerifyBinaryData(cnn); frm.WriteLine("SUCCESS - VerifyBinaryData"); }
catch (Exception) { frm.WriteLine("FAIL - VerifyBinaryData"); }
try { VerifyBinaryData(cnn); frm.WriteLine("SUCCESS - VerifyBinaryData"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - VerifyBinaryData"); failed++; }
total++;
try { LockTest(cnn); frm.WriteLine("SUCCESS - LockTest"); }
catch (Exception) { frm.WriteLine("FAIL - LockTest"); }
try { LockTest(cnn); frm.WriteLine("SUCCESS - LockTest"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - LockTest"); failed++; }
total++;
try { ParameterizedInsertMissingParams(cnn); frm.WriteLine("FAIL - ParameterizedInsertMissingParams"); }
catch (Exception) { frm.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); }
try { ParameterizedInsertMissingParams(cnn); frm.WriteLine("FAIL - ParameterizedInsertMissingParams"); failed++; }
catch (Exception) { frm.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); passed++; }
total++;
try { InsertMany(cnn, false); frm.WriteLine("SUCCESS - InsertMany"); }
catch (Exception) { frm.WriteLine("FAIL - InsertMany"); }
try { InsertMany(cnn, false); frm.WriteLine("SUCCESS - InsertMany"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - InsertMany"); failed++; }
total++;
try { InsertMany(cnn, true); frm.WriteLine("SUCCESS - InsertManyWithIdentityFetch"); }
catch (Exception) { frm.WriteLine("FAIL - InsertManyWithIdentityFetch"); }
try { InsertMany(cnn, true); frm.WriteLine("SUCCESS - InsertManyWithIdentityFetch"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - InsertManyWithIdentityFetch"); failed++; }
total++;
try { FastInsertMany(cnn); frm.WriteLine("SUCCESS - FastInsertMany"); }
catch (Exception) { frm.WriteLine("FAIL - FastInsertMany"); }
try { FastInsertMany(cnn); frm.WriteLine("SUCCESS - FastInsertMany"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - FastInsertMany"); failed++; }
total++;
try { IterationTest(cnn); frm.WriteLine("SUCCESS - Iteration Test"); }
catch (Exception) { frm.WriteLine("FAIL - Iteration Test"); }
try { IterationTest(cnn); frm.WriteLine("SUCCESS - Iteration Test"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - Iteration Test"); failed++; }
total++;
try { UserFunction(cnn); frm.WriteLine("SUCCESS - UserFunction"); }
catch (Exception) { frm.WriteLine("FAIL - UserFunction"); }
try { UserFunction(cnn); frm.WriteLine("SUCCESS - UserFunction"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - UserFunction"); failed++; }
total++;
try { UserAggregate(cnn); frm.WriteLine("SUCCESS - UserAggregate"); }
catch (Exception) { frm.WriteLine("FAIL - UserAggregate"); }
try { UserAggregate(cnn); frm.WriteLine("SUCCESS - UserAggregate"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - UserAggregate"); failed++; }
total++;
try { UserCollation(cnn); frm.WriteLine("SUCCESS - UserCollation"); }
catch (Exception) { frm.WriteLine("FAIL - UserCollation"); }
try { UserCollation(cnn); frm.WriteLine("SUCCESS - UserCollation"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - UserCollation"); failed++; }
total++;
try { DropTable(cnn); frm.WriteLine("SUCCESS - DropTable"); }
catch (Exception) { frm.WriteLine("FAIL - DropTable"); }
try { DropTable(cnn); frm.WriteLine("SUCCESS - DropTable"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - DropTable"); failed++; }
frm.WriteLine("\r\nTests Finished.");
frm.WriteLine(String.Format("\r\nCounts: {0} total, {1} passed, {2} failed", total, passed, failed));
frm.WriteLine(String.Format("Result: {0}", Succeeded() ? "SUCCESS" : "FAILURE"));
if (autoClose)
frm.Close();
}
internal static void KeyInfoTest(DbConnection cnn)
{
using (DbCommand cmd = cnn.CreateCommand())
{
// First test against integer primary key (optimized) keyinfo fetch
|