1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Collections;
|
21
|
|
using System.Data;
|
22
|
|
using System.Data.SqlTypes;
|
23
|
|
using Nullables;
|
24
|
|
using MbUnit.Framework;
|
25
|
|
using Seasar.Extension.Unit;
|
26
|
|
|
27
|
|
namespace Seasar.Tests.Extension.Unit
|
28
|
|
{
|
29
|
|
[TestFixture]
|
30
|
|
public class DictionaryReaderTest
|
31
|
|
{
|
32
|
1
|
[Test]
|
33
|
|
public void TestReadPrimitiveType()
|
34
|
|
{
|
35
|
1
|
IDictionary dictionary = new Hashtable();
|
36
|
1
|
dictionary.Add("Id", 1L);
|
37
|
1
|
dictionary.Add("BoolType", true);
|
38
|
1
|
dictionary.Add("SbyteType", SByte.MaxValue);
|
39
|
1
|
dictionary.Add("ByteType", Byte.MaxValue);
|
40
|
1
|
dictionary.Add("Int16Type", Int16.MaxValue);
|
41
|
1
|
dictionary.Add("Int32Type", Int32.MaxValue);
|
42
|
1
|
dictionary.Add("Int64Type", Int64.MaxValue);
|
43
|
1
|
dictionary.Add("DecimalType", Decimal.MaxValue);
|
44
|
1
|
dictionary.Add("SingleType", Single.MaxValue);
|
45
|
1
|
dictionary.Add("DoubleType", Double.MaxValue);
|
46
|
1
|
dictionary.Add("StringType", "abcde");
|
47
|
1
|
dictionary.Add("DateTimeType", new DateTime(1999, 12, 31));
|
48
|
|
|
49
|
1
|
DictionaryReader reader = new DictionaryReader(dictionary);
|
50
|
1
|
DataSet ds = reader.Read();
|
51
|
1
|
DataTable table = ds.Tables[0];
|
52
|
1
|
DataRow row = table.Rows[0];
|
53
|
1
|
DataColumnCollection columns = table.Columns;
|
54
|
|
|
55
|
1
|
Assert.AreEqual(DataRowState.Unchanged, row.RowState);
|
56
|
1
|
Assert.AreEqual(12, columns.Count);
|
57
|
|
|
58
|
1
|
Assert.AreEqual(1, row["id"]);
|
59
|
1
|
Assert.AreEqual(true, row["booltype"]);
|
60
|
1
|
Assert.AreEqual(SByte.MaxValue, row["sbytetype"]);
|
61
|
1
|
Assert.AreEqual(Byte.MaxValue, row["bytetype"]);
|
62
|
1
|
Assert.AreEqual(Int16.MaxValue, row["int16type"]);
|
63
|
1
|
Assert.AreEqual(Int32.MaxValue, row["int32type"]);
|
64
|
1
|
Assert.AreEqual(Int64.MaxValue, row["int64type"]);
|
65
|
1
|
Assert.AreEqual(Decimal.MaxValue, row["decimaltype"]);
|
66
|
1
|
Assert.AreEqual(Single.MaxValue, row["singletype"]);
|
67
|
1
|
Assert.AreEqual(Double.MaxValue, row["doubletype"]);
|
68
|
1
|
Assert.AreEqual("abcde", row["stringtype"]);
|
69
|
1
|
Assert.AreEqual(new DateTime(1999, 12, 31), row["datetimetype"]);
|
70
|
|
|
71
|
1
|
Assert.AreEqual(typeof(long), columns["id"].DataType);
|
72
|
1
|
Assert.AreEqual(typeof(bool), columns["booltype"].DataType);
|
73
|
1
|
Assert.AreEqual(typeof(sbyte), columns["sbytetype"].DataType);
|
74
|
1
|
Assert.AreEqual(typeof(byte), columns["bytetype"].DataType);
|
75
|
1
|
Assert.AreEqual(typeof(short), columns["int16type"].DataType);
|
76
|
1
|
Assert.AreEqual(typeof(int), columns["int32type"].DataType);
|
77
|
1
|
Assert.AreEqual(typeof(long), columns["int64type"].DataType);
|
78
|
1
|
Assert.AreEqual(typeof(decimal), columns["decimaltype"].DataType);
|
79
|
1
|
Assert.AreEqual(typeof(float), columns["singletype"].DataType);
|
80
|
1
|
Assert.AreEqual(typeof(double), columns["doubletype"].DataType);
|
81
|
1
|
Assert.AreEqual(typeof(string), columns["stringtype"].DataType);
|
82
|
1
|
Assert.AreEqual(typeof(DateTime), columns["datetimetype"].DataType);
|
83
|
|
}
|
84
|
|
|
85
|
1
|
[Test]
|
86
|
|
public void TestReadNHibernateNullableType()
|
87
|
|
{
|
88
|
1
|
IDictionary dictionary = new Hashtable();
|
89
|
1
|
dictionary.Add("Id", new NullableInt64(1L));
|
90
|
1
|
dictionary.Add("BoolType", new NullableBoolean(true));
|
91
|
1
|
dictionary.Add("SbyteType", new NullableSByte(SByte.MaxValue));
|
92
|
1
|
dictionary.Add("ByteType", new NullableByte(Byte.MaxValue));
|
93
|
1
|
dictionary.Add("Int16Type", new NullableInt16(Int16.MaxValue));
|
94
|
1
|
dictionary.Add("Int32Type", new NullableInt32(Int32.MaxValue));
|
95
|
1
|
dictionary.Add("Int64Type", new NullableInt64(Int64.MaxValue));
|
96
|
1
|
dictionary.Add("DecimalType", new NullableDecimal(Decimal.MaxValue));
|
97
|
1
|
dictionary.Add("SingleType", new NullableSingle(Single.MaxValue));
|
98
|
1
|
dictionary.Add("DoubleType", new NullableDouble(Double.MaxValue));
|
99
|
1
|
dictionary.Add("StringType", "abcde");
|
100
|
1
|
dictionary.Add("DateTimeType", new NullableDateTime(new DateTime(1999, 12, 31)));
|
101
|
|
|
102
|
1
|
DictionaryReader reader = new DictionaryReader(dictionary);
|
103
|
1
|
DataSet ds = reader.Read();
|
104
|
1
|
DataTable table = ds.Tables[0];
|
105
|
1
|
DataRow row = table.Rows[0];
|
106
|
1
|
DataColumnCollection columns = table.Columns;
|
107
|
|
|
108
|
1
|
Assert.AreEqual(DataRowState.Unchanged, row.RowState);
|
109
|
1
|
Assert.AreEqual(12, columns.Count);
|
110
|
|
|
111
|
1
|
Assert.AreEqual(1, row["id"]);
|
112
|
1
|
Assert.AreEqual(true, row["booltype"]);
|
113
|
1
|
Assert.AreEqual(SByte.MaxValue, row["sbytetype"]);
|
114
|
1
|
Assert.AreEqual(Byte.MaxValue, row["bytetype"]);
|
115
|
1
|
Assert.AreEqual(Int16.MaxValue, row["int16type"]);
|
116
|
1
|
Assert.AreEqual(Int32.MaxValue, row["int32type"]);
|
117
|
1
|
Assert.AreEqual(Int64.MaxValue, row["int64type"]);
|
118
|
1
|
Assert.AreEqual(Decimal.MaxValue, row["decimaltype"]);
|
119
|
1
|
Assert.AreEqual(Single.MaxValue, row["singletype"]);
|
120
|
1
|
Assert.AreEqual(Double.MaxValue, row["doubletype"]);
|
121
|
1
|
Assert.AreEqual("abcde", row["stringtype"]);
|
122
|
1
|
Assert.AreEqual(new DateTime(1999, 12, 31), row["datetimetype"]);
|
123
|
|
|
124
|
1
|
Assert.AreEqual(typeof(long), columns["id"].DataType);
|
125
|
1
|
Assert.AreEqual(typeof(bool), columns["booltype"].DataType);
|
126
|
1
|
Assert.AreEqual(typeof(sbyte), columns["sbytetype"].DataType);
|
127
|
1
|
Assert.AreEqual(typeof(byte), columns["bytetype"].DataType);
|
128
|
1
|
Assert.AreEqual(typeof(short), columns["int16type"].DataType);
|
129
|
1
|
Assert.AreEqual(typeof(int), columns["int32type"].DataType);
|
130
|
1
|
Assert.AreEqual(typeof(long), columns["int64type"].DataType);
|
131
|
1
|
Assert.AreEqual(typeof(decimal), columns["decimaltype"].DataType);
|
132
|
1
|
Assert.AreEqual(typeof(float), columns["singletype"].DataType);
|
133
|
1
|
Assert.AreEqual(typeof(double), columns["doubletype"].DataType);
|
134
|
1
|
Assert.AreEqual(typeof(string), columns["stringtype"].DataType);
|
135
|
1
|
Assert.AreEqual(typeof(DateTime), columns["datetimetype"].DataType);
|
136
|
|
}
|
137
|
|
|
138
|
1
|
[Test]
|
139
|
|
public void TestReadNHibernateNullableTypeNullValue()
|
140
|
|
{
|
141
|
1
|
IDictionary dictionary = new Hashtable();
|
142
|
1
|
dictionary.Add("Id", new NullableInt64());
|
143
|
1
|
dictionary.Add("BoolType", new NullableBoolean());
|
144
|
1
|
dictionary.Add("SbyteType", new NullableSByte());
|
145
|
1
|
dictionary.Add("ByteType", new NullableByte());
|
146
|
1
|
dictionary.Add("Int16Type", new NullableInt16());
|
147
|
1
|
dictionary.Add("Int32Type", new NullableInt32());
|
148
|
1
|
dictionary.Add("Int64Type", new NullableInt64());
|
149
|
1
|
dictionary.Add("DecimalType", new NullableDecimal());
|
150
|
1
|
dictionary.Add("SingleType", new NullableSingle());
|
151
|
1
|
dictionary.Add("DoubleType", new NullableDouble());
|
152
|
1
|
dictionary.Add("StringType", null);
|
153
|
1
|
dictionary.Add("DateTimeType", new NullableDateTime());
|
154
|
|
|
155
|
1
|
DictionaryReader reader = new DictionaryReader(dictionary);
|
156
|
1
|
DataSet ds = reader.Read();
|
157
|
1
|
DataTable table = ds.Tables[0];
|
158
|
1
|
DataRow row = table.Rows[0];
|
159
|
1
|
DataColumnCollection columns = table.Columns;
|
160
|
|
|
161
|
1
|
Assert.AreEqual(DataRowState.Unchanged, row.RowState);
|
162
|
1
|
Assert.AreEqual(12, columns.Count);
|
163
|
|
|
164
|
1
|
Assert.AreEqual(DBNull.Value, row["id"]);
|
165
|
1
|
Assert.AreEqual(DBNull.Value, row["booltype"]);
|
166
|
1
|
Assert.AreEqual(DBNull.Value, row["sbytetype"]);
|
167
|
1
|
Assert.AreEqual(DBNull.Value, row["bytetype"]);
|
168
|
1
|
Assert.AreEqual(DBNull.Value, row["int16type"]);
|
169
|
1
|
Assert.AreEqual(DBNull.Value, row["int32type"]);
|
170
|
1
|
Assert.AreEqual(DBNull.Value, row["int64type"]);
|
171
|
1
|
Assert.AreEqual(DBNull.Value, row["decimaltype"]);
|
172
|
1
|
Assert.AreEqual(DBNull.Value, row["singletype"]);
|
173
|
1
|
Assert.AreEqual(DBNull.Value, row["doubletype"]);
|
174
|
1
|
Assert.AreEqual(DBNull.Value, row["stringtype"]);
|
175
|
1
|
Assert.AreEqual(DBNull.Value, row["datetimetype"]);
|
176
|
|
|
177
|
1
|
Assert.AreEqual(typeof(long), columns["id"].DataType);
|
178
|
1
|
Assert.AreEqual(typeof(bool), columns["booltype"].DataType);
|
179
|
1
|
Assert.AreEqual(typeof(sbyte), columns["sbytetype"].DataType);
|
180
|
1
|
Assert.AreEqual(typeof(byte), columns["bytetype"].DataType);
|
181
|
1
|
Assert.AreEqual(typeof(short), columns["int16type"].DataType);
|
182
|
1
|
Assert.AreEqual(typeof(int), columns["int32type"].DataType);
|
183
|
1
|
Assert.AreEqual(typeof(long), columns["int64type"].DataType);
|
184
|
1
|
Assert.AreEqual(typeof(decimal), columns["decimaltype"].DataType);
|
185
|
1
|
Assert.AreEqual(typeof(float), columns["singletype"].DataType);
|
186
|
1
|
Assert.AreEqual(typeof(double), columns["doubletype"].DataType);
|
187
|
1
|
Assert.AreEqual(typeof(string), columns["stringtype"].DataType);
|
188
|
1
|
Assert.AreEqual(typeof(DateTime), columns["datetimetype"].DataType);
|
189
|
|
}
|
190
|
|
|
191
|
1
|
[Test]
|
192
|
|
public void TestReadNullableType()
|
193
|
|
{
|
194
|
1
|
IDictionary dictionary = new Hashtable();
|
195
|
1
|
dictionary.Add("Id", new Nullable<long>(1L));
|
196
|
1
|
dictionary.Add("BoolType", new Nullable<bool>(true));
|
197
|
1
|
dictionary.Add("SbyteType", new Nullable<sbyte>(SByte.MaxValue));
|
198
|
1
|
dictionary.Add("ByteType", new Nullable<byte>(Byte.MaxValue));
|
199
|
1
|
dictionary.Add("Int16Type", new Nullable<short>(Int16.MaxValue));
|
200
|
1
|
dictionary.Add("Int32Type", new Nullable<int>(Int32.MaxValue));
|
201
|
1
|
dictionary.Add("Int64Type", new Nullable<long>(Int64.MaxValue));
|
202
|
1
|
dictionary.Add("DecimalType", new Nullable<decimal>(Decimal.MaxValue));
|
203
|
1
|
dictionary.Add("SingleType", new Nullable<float>(Single.MaxValue));
|
204
|
1
|
dictionary.Add("DoubleType", new Nullable<double>(Double.MaxValue));
|
205
|
1
|
dictionary.Add("StringType", "abcde");
|
206
|
1
|
dictionary.Add("DateTimeType", new Nullable<DateTime>(new DateTime(1999, 12, 31)));
|
207
|
|
|
208
|
1
|
DictionaryReader reader = new DictionaryReader(dictionary);
|
209
|
1
|
DataSet ds = reader.Read();
|
210
|
1
|
DataTable table = ds.Tables[0];
|
211
|
1
|
DataRow row = table.Rows[0];
|
212
|
1
|
DataColumnCollection columns = table.Columns;
|
213
|
|
|
214
|
1
|
Assert.AreEqual(DataRowState.Unchanged, row.RowState);
|
215
|
1
|
Assert.AreEqual(12, columns.Count);
|
216
|
|
|
217
|
1
|
Assert.AreEqual(1, row["id"]);
|
218
|
1
|
Assert.AreEqual(true, row["booltype"]);
|
219
|
1
|
Assert.AreEqual(SByte.MaxValue, row["sbytetype"]);
|
220
|
1
|
Assert.AreEqual(Byte.MaxValue, row["bytetype"]);
|
221
|
1
|
Assert.AreEqual(Int16.MaxValue, row["int16type"]);
|
222
|
1
|
Assert.AreEqual(Int32.MaxValue, row["int32type"]);
|
223
|
1
|
Assert.AreEqual(Int64.MaxValue, row["int64type"]);
|
224
|
1
|
Assert.AreEqual(Decimal.MaxValue, row["decimaltype"]);
|
225
|
1
|
Assert.AreEqual(Single.MaxValue, row["singletype"]);
|
226
|
1
|
Assert.AreEqual(Double.MaxValue, row["doubletype"]);
|
227
|
1
|
Assert.AreEqual("abcde", row["stringtype"]);
|
228
|
1
|
Assert.AreEqual(new DateTime(1999, 12, 31), row["datetimetype"]);
|
229
|
|
|
230
|
1
|
Assert.AreEqual(typeof(long), columns["id"].DataType);
|
231
|
1
|
Assert.AreEqual(typeof(bool), columns["booltype"].DataType);
|
232
|
1
|
Assert.AreEqual(typeof(sbyte), columns["sbytetype"].DataType);
|
233
|
1
|
Assert.AreEqual(typeof(byte), columns["bytetype"].DataType);
|
234
|
1
|
Assert.AreEqual(typeof(short), columns["int16type"].DataType);
|
235
|
1
|
Assert.AreEqual(typeof(int), columns["int32type"].DataType);
|
236
|
1
|
Assert.AreEqual(typeof(long), columns["int64type"].DataType);
|
237
|
1
|
Assert.AreEqual(typeof(decimal), columns["decimaltype"].DataType);
|
238
|
1
|
Assert.AreEqual(typeof(float), columns["singletype"].DataType);
|
239
|
1
|
Assert.AreEqual(typeof(double), columns["doubletype"].DataType);
|
240
|
1
|
Assert.AreEqual(typeof(string), columns["stringtype"].DataType);
|
241
|
1
|
Assert.AreEqual(typeof(DateTime), columns["datetimetype"].DataType);
|
242
|
|
}
|
243
|
|
|
244
|
0
|
[Test]
|
245
|
|
[Ignore("Nullable<T>.Valueがnullだと型情報を取得できないので、DataType設定不可。")]
|
246
|
|
public void TestReadNullableTypeNullValue()
|
247
|
|
{
|
248
|
|
IDictionary dictionary = new Hashtable();
|
249
|
|
dictionary.Add("Id", new Nullable<long>());
|
250
|
|
dictionary.Add("BoolType", new Nullable<bool>());
|
251
|
|
dictionary.Add("SbyteType", new Nullable<sbyte>());
|
252
|
|
dictionary.Add("ByteType", new Nullable<byte>());
|
253
|
|
dictionary.Add("Int16Type", new Nullable<short>());
|
254
|
|
dictionary.Add("Int32Type", new Nullable<int>());
|
255
|
|
dictionary.Add("Int64Type", new Nullable<long>());
|
256
|
|
dictionary.Add("DecimalType", new Nullable<decimal>());
|
257
|
|
dictionary.Add("SingleType", new Nullable<float>());
|
258
|
|
dictionary.Add("DoubleType", new Nullable<double>());
|
259
|
|
dictionary.Add("StringType", null);
|
260
|
|
dictionary.Add("DateTimeType", new Nullable<DateTime>());
|
261
|
|
|
262
|
|
DictionaryReader reader = new DictionaryReader(dictionary);
|
263
|
|
DataSet ds = reader.Read();
|
264
|
|
DataTable table = ds.Tables[0];
|
265
|
|
DataRow row = table.Rows[0];
|
266
|
|
DataColumnCollection columns = table.Columns;
|
267
|
|
|
268
|
|
Assert.AreEqual(DataRowState.Unchanged, row.RowState);
|
269
|
|
Assert.AreEqual(12, columns.Count);
|
270
|
|
|
271
|
|
Assert.AreEqual(DBNull.Value, row["id"]);
|
272
|
|
Assert.AreEqual(DBNull.Value, row["booltype"]);
|
273
|
|
Assert.AreEqual(DBNull.Value, row["sbytetype"]);
|
274
|
|
Assert.AreEqual(DBNull.Value, row["bytetype"]);
|
275
|
|
Assert.AreEqual(DBNull.Value, row["int16type"]);
|
276
|
|
Assert.AreEqual(DBNull.Value, row["int32type"]);
|
277
|
|
Assert.AreEqual(DBNull.Value, row["int64type"]);
|
278
|
|
Assert.AreEqual(DBNull.Value, row["decimaltype"]);
|
279
|
|
Assert.AreEqual(DBNull.Value, row["singletype"]);
|
280
|
|
Assert.AreEqual(DBNull.Value, row["doubletype"]);
|
281
|
|
Assert.AreEqual(DBNull.Value, row["stringtype"]);
|
282
|
|
Assert.AreEqual(DBNull.Value, row["datetimetype"]);
|
283
|
|
|
284
|
|
Assert.AreEqual(typeof(long), columns["id"].DataType);
|
285
|
|
Assert.AreEqual(typeof(bool), columns["booltype"].DataType);
|
286
|
|
Assert.AreEqual(typeof(sbyte), columns["sbytetype"].DataType);
|
287
|
|
Assert.AreEqual(typeof(byte), columns["bytetype"].DataType);
|
288
|
|
Assert.AreEqual(typeof(short), columns["int16type"].DataType);
|
289
|
|
Assert.AreEqual(typeof(int), columns["int32type"].DataType);
|
290
|
|
Assert.AreEqual(typeof(long), columns["int64type"].DataType);
|
291
|
|
Assert.AreEqual(typeof(decimal), columns["decimaltype"].DataType);
|
292
|
|
Assert.AreEqual(typeof(float), columns["singletype"].DataType);
|
293
|
|
Assert.AreEqual(typeof(double), columns["doubletype"].DataType);
|
294
|
|
Assert.AreEqual(typeof(string), columns["stringtype"].DataType);
|
295
|
|
Assert.AreEqual(typeof(DateTime), columns["datetimetype"].DataType);
|
296
|
|
}
|
297
|
|
|
298
|
1
|
[Test]
|
299
|
|
public void TestReadSqlType()
|
300
|
|
{
|
301
|
1
|
IDictionary dictionary = new Hashtable();
|
302
|
1
|
dictionary.Add("Id", new SqlInt64(1L));
|
303
|
1
|
dictionary.Add("BoolType", new SqlBoolean(true));
|
304
|
1
|
dictionary.Add("ByteType", new SqlByte(Byte.MaxValue));
|
305
|
1
|
dictionary.Add("Int16Type", new SqlInt16(Int16.MaxValue));
|
306
|
1
|
dictionary.Add("Int32Type", new SqlInt32(Int32.MaxValue));
|
307
|
1
|
dictionary.Add("Int64Type", new SqlInt64(Int64.MaxValue));
|
308
|
1
|
dictionary.Add("DecimalType", new SqlDecimal(Decimal.MaxValue));
|
309
|
1
|
dictionary.Add("SingleType", new SqlSingle(Single.MaxValue));
|
310
|
1
|
dictionary.Add("DoubleType", new SqlDouble(Double.MaxValue));
|
311
|
1
|
dictionary.Add("StringType", new SqlString("abcde"));
|
312
|
1
|
dictionary.Add("DateTimeType", new SqlDateTime(new DateTime(1999, 12, 31)));
|
313
|
|
|
314
|
1
|
DictionaryReader reader = new DictionaryReader(dictionary);
|
315
|
1
|
DataSet ds = reader.Read();
|
316
|
1
|
DataTable table = ds.Tables[0];
|
317
|
1
|
DataRow row = table.Rows[0];
|
318
|
1
|
DataColumnCollection columns = table.Columns;
|
319
|
|
|
320
|
1
|
Assert.AreEqual(DataRowState.Unchanged, row.RowState);
|
321
|
1
|
Assert.AreEqual(11, columns.Count);
|
322
|
|
|
323
|
1
|
Assert.AreEqual(1, row["id"]);
|
324
|
1
|
Assert.AreEqual(true, row["booltype"]);
|
325
|
1
|
Assert.AreEqual(Byte.MaxValue, row["bytetype"]);
|
326
|
1
|
Assert.AreEqual(Int16.MaxValue, row["int16type"]);
|
327
|
1
|
Assert.AreEqual(Int32.MaxValue, row["int32type"]);
|
328
|
1
|
Assert.AreEqual(Int64.MaxValue, row["int64type"]);
|
329
|
1
|
Assert.AreEqual(Decimal.MaxValue, row["decimaltype"]);
|
330
|
1
|
Assert.AreEqual(Single.MaxValue, row["singletype"]);
|
331
|
1
|
Assert.AreEqual(Double.MaxValue, row["doubletype"]);
|
332
|
1
|
Assert.AreEqual("abcde", row["stringtype"]);
|
333
|
1
|
Assert.AreEqual(new DateTime(1999, 12, 31), row["datetimetype"]);
|
334
|
|
|
335
|
1
|
Assert.AreEqual(typeof(long), columns["id"].DataType);
|
336
|
1
|
Assert.AreEqual(typeof(bool), columns["booltype"].DataType);
|
337
|
1
|
Assert.AreEqual(typeof(byte), columns["bytetype"].DataType);
|
338
|
1
|
Assert.AreEqual(typeof(short), columns["int16type"].DataType);
|
339
|
1
|
Assert.AreEqual(typeof(int), columns["int32type"].DataType);
|
340
|
1
|
Assert.AreEqual(typeof(long), columns["int64type"].DataType);
|
341
|
1
|
Assert.AreEqual(typeof(decimal), columns["decimaltype"].DataType);
|
342
|
1
|
Assert.AreEqual(typeof(float), columns["singletype"].DataType);
|
343
|
1
|
Assert.AreEqual(typeof(double), columns["doubletype"].DataType);
|
344
|
1
|
Assert.AreEqual(typeof(string), columns["stringtype"].DataType);
|
345
|
1
|
Assert.AreEqual(typeof(DateTime), columns["datetimetype"].DataType);
|
346
|
|
}
|
347
|
|
|
348
|
1
|
[Test]
|
349
|
|
public void TestReadSqlTypeNullValue()
|
350
|
|
{
|
351
|
1
|
IDictionary dictionary = new Hashtable();
|
352
|
1
|
dictionary.Add("Id", SqlInt64.Null);
|
353
|
1
|
dictionary.Add("BoolType", SqlBoolean.Null);
|
354
|
1
|
dictionary.Add("ByteType", SqlByte.Null);
|
355
|
1
|
dictionary.Add("Int16Type", SqlInt16.Null);
|
356
|
1
|
dictionary.Add("Int32Type", SqlInt32.Null);
|
357
|
1
|
dictionary.Add("Int64Type", SqlInt64.Null);
|
358
|
1
|
dictionary.Add("DecimalType", SqlDecimal.Null);
|
359
|
1
|
dictionary.Add("SingleType", SqlSingle.Null);
|
360
|
1
|
dictionary.Add("DoubleType", SqlDouble.Null);
|
361
|
1
|
dictionary.Add("StringType", SqlString.Null);
|
362
|
1
|
dictionary.Add("DateTimeType", SqlDateTime.Null);
|
363
|
|
|
364
|
1
|
DictionaryReader reader = new DictionaryReader(dictionary);
|
365
|
1
|
DataSet ds = reader.Read();
|
366
|
1
|
DataTable table = ds.Tables[0];
|
367
|
1
|
DataRow row = table.Rows[0];
|
368
|
1
|
DataColumnCollection columns = table.Columns;
|
369
|
|
|
370
|
1
|
Assert.AreEqual(DataRowState.Unchanged, row.RowState);
|
371
|
1
|
Assert.AreEqual(11, columns.Count);
|
372
|
|
|
373
|
1
|
Assert.AreEqual(DBNull.Value, row["id"]);
|
374
|
1
|
Assert.AreEqual(DBNull.Value, row["booltype"]);
|
375
|
1
|
Assert.AreEqual(DBNull.Value, row["bytetype"]);
|
376
|
1
|
Assert.AreEqual(DBNull.Value, row["int16type"]);
|
377
|
1
|
Assert.AreEqual(DBNull.Value, row["int32type"]);
|
378
|
1
|
Assert.AreEqual(DBNull.Value, row["int64type"]);
|
379
|
1
|
Assert.AreEqual(DBNull.Value, row["decimaltype"]);
|
380
|
1
|
Assert.AreEqual(DBNull.Value, row["singletype"]);
|
381
|
1
|
Assert.AreEqual(DBNull.Value, row["doubletype"]);
|
382
|
1
|
Assert.AreEqual(DBNull.Value, row["stringtype"]);
|
383
|
1
|
Assert.AreEqual(DBNull.Value, row["datetimetype"]);
|
384
|
|
|
385
|
1
|
Assert.AreEqual(typeof(long), columns["id"].DataType);
|
386
|
1
|
Assert.AreEqual(typeof(bool), columns["booltype"].DataType);
|
387
|
1
|
Assert.AreEqual(typeof(byte), columns["bytetype"].DataType);
|
388
|
1
|
Assert.AreEqual(typeof(short), columns["int16type"].DataType);
|
389
|
1
|
Assert.AreEqual(typeof(int), columns["int32type"].DataType);
|
390
|
1
|
Assert.AreEqual(typeof(long), columns["int64type"].DataType);
|
391
|
1
|
Assert.AreEqual(typeof(decimal), columns["decimaltype"].DataType);
|
392
|
1
|
Assert.AreEqual(typeof(float), columns["singletype"].DataType);
|
393
|
1
|
Assert.AreEqual(typeof(double), columns["doubletype"].DataType);
|
394
|
1
|
Assert.AreEqual(typeof(string), columns["stringtype"].DataType);
|
395
|
1
|
Assert.AreEqual(typeof(DateTime), columns["datetimetype"].DataType);
|
396
|
|
}
|
397
|
|
}
|
398
|
|
}
|
399
|
|
|