|
17 | 17 |
|
18 | 18 | using System;
|
19 | 19 | using System.Collections;
|
| 20 | +using System.Linq; |
20 | 21 | using System.Security.Cryptography;
|
21 | 22 | using FirebirdSql.Data.FirebirdClient;
|
22 | 23 | using FirebirdSql.Data.TestsBase;
|
@@ -71,12 +72,8 @@ public void IntegerArrayTest()
|
71 | 72 | if (!reader.IsDBNull(0))
|
72 | 73 | {
|
73 | 74 | int[] select_values = new int[insert_values.Length];
|
74 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
75 |
| - |
76 |
| - for (int i = 0; i < insert_values.Length; i++) |
77 |
| - { |
78 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
79 |
| - } |
| 75 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 76 | + CollectionAssert.AreEqual(insert_values, select_values); |
80 | 77 | }
|
81 | 78 | }
|
82 | 79 | reader.Close();
|
@@ -115,12 +112,8 @@ public void ShortArrayTest()
|
115 | 112 | if (!reader.IsDBNull(0))
|
116 | 113 | {
|
117 | 114 | short[] select_values = new short[insert_values.Length];
|
118 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
119 |
| - |
120 |
| - for (int i = 0; i < insert_values.Length; i++) |
121 |
| - { |
122 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
123 |
| - } |
| 115 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 116 | + CollectionAssert.AreEqual(insert_values, select_values); |
124 | 117 | }
|
125 | 118 | }
|
126 | 119 | reader.Close();
|
@@ -159,12 +152,8 @@ public void BigIntArrayTest()
|
159 | 152 | if (!reader.IsDBNull(0))
|
160 | 153 | {
|
161 | 154 | long[] select_values = new long[insert_values.Length];
|
162 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
163 |
| - |
164 |
| - for (int i = 0; i < insert_values.Length; i++) |
165 |
| - { |
166 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
167 |
| - } |
| 155 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 156 | + CollectionAssert.AreEqual(insert_values, select_values); |
168 | 157 | }
|
169 | 158 | }
|
170 | 159 | reader.Close();
|
@@ -203,12 +192,8 @@ public void FloatArrayTest()
|
203 | 192 | if (!reader.IsDBNull(0))
|
204 | 193 | {
|
205 | 194 | float[] select_values = new float[insert_values.Length];
|
206 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
207 |
| - |
208 |
| - for (int i = 0; i < insert_values.Length; i++) |
209 |
| - { |
210 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
211 |
| - } |
| 195 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 196 | + CollectionAssert.AreEqual(insert_values, select_values); |
212 | 197 | }
|
213 | 198 | }
|
214 | 199 | reader.Close();
|
@@ -247,12 +232,8 @@ public void DoubleArrayTest()
|
247 | 232 | if (!reader.IsDBNull(0))
|
248 | 233 | {
|
249 | 234 | double[] select_values = new double[insert_values.Length];
|
250 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
251 |
| - |
252 |
| - for (int i = 0; i < insert_values.Length; i++) |
253 |
| - { |
254 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
255 |
| - } |
| 235 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 236 | + CollectionAssert.AreEqual(insert_values, select_values); |
256 | 237 | }
|
257 | 238 | }
|
258 | 239 | reader.Close();
|
@@ -291,12 +272,8 @@ public void NumericArrayTest()
|
291 | 272 | if (!reader.IsDBNull(0))
|
292 | 273 | {
|
293 | 274 | decimal[] select_values = new decimal[insert_values.Length];
|
294 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
295 |
| - |
296 |
| - for (int i = 0; i < insert_values.Length; i++) |
297 |
| - { |
298 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
299 |
| - } |
| 275 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 276 | + CollectionAssert.AreEqual(insert_values, select_values); |
300 | 277 | }
|
301 | 278 | }
|
302 | 279 | reader.Close();
|
@@ -335,12 +312,8 @@ public void DateArrayTest()
|
335 | 312 | if (!reader.IsDBNull(0))
|
336 | 313 | {
|
337 | 314 | DateTime[] select_values = new DateTime[insert_values.Length];
|
338 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
339 |
| - |
340 |
| - for (int i = 0; i < insert_values.Length; i++) |
341 |
| - { |
342 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
343 |
| - } |
| 315 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 316 | + CollectionAssert.AreEqual(insert_values, select_values); |
344 | 317 | }
|
345 | 318 | }
|
346 | 319 | reader.Close();
|
@@ -379,12 +352,8 @@ public void TimeArrayTest()
|
379 | 352 | if (!reader.IsDBNull(0))
|
380 | 353 | {
|
381 | 354 | TimeSpan[] select_values = new TimeSpan[insert_values.Length];
|
382 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
383 |
| - |
384 |
| - for (int i = 0; i < insert_values.Length; i++) |
385 |
| - { |
386 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
387 |
| - } |
| 355 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 356 | + CollectionAssert.AreEqual(insert_values, select_values); |
388 | 357 | }
|
389 | 358 | }
|
390 | 359 | reader.Close();
|
@@ -423,13 +392,9 @@ public void TimeStampArrayTest()
|
423 | 392 | if (!reader.IsDBNull(0))
|
424 | 393 | {
|
425 | 394 | DateTime[] select_values = new DateTime[insert_values.Length];
|
426 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
427 |
| - |
428 |
| - for (int i = 0; i < insert_values.Length; i++) |
429 |
| - { |
430 |
| - var truncatedPrecision = new DateTime(insert_values[i].Ticks / 1000 * 1000); |
431 |
| - Assert.AreEqual(truncatedPrecision, select_values[i]); |
432 |
| - } |
| 395 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 396 | + insert_values = insert_values.Select(x => new DateTime(x.Ticks / 1000 * 1000)).ToArray(); |
| 397 | + CollectionAssert.AreEqual(insert_values, select_values); |
433 | 398 | }
|
434 | 399 | }
|
435 | 400 | reader.Close();
|
@@ -468,12 +433,9 @@ public void CharArrayTest()
|
468 | 433 | if (!reader.IsDBNull(0))
|
469 | 434 | {
|
470 | 435 | string[] select_values = new string[insert_values.Length];
|
471 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
472 |
| - |
473 |
| - for (int i = 0; i < insert_values.Length; i++) |
474 |
| - { |
475 |
| - Assert.AreEqual(insert_values[i], select_values[i].TrimEnd(' ')); |
476 |
| - } |
| 436 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 437 | + select_values = select_values.Select(x => x.TrimEnd(' ')).ToArray(); |
| 438 | + CollectionAssert.AreEqual(insert_values, select_values); |
477 | 439 | }
|
478 | 440 | }
|
479 | 441 | reader.Close();
|
@@ -512,12 +474,8 @@ public void VarCharArrayTest()
|
512 | 474 | if (!reader.IsDBNull(0))
|
513 | 475 | {
|
514 | 476 | string[] select_values = new string[insert_values.Length];
|
515 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
516 |
| - |
517 |
| - for (int i = 0; i < insert_values.Length; i++) |
518 |
| - { |
519 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
520 |
| - } |
| 477 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 478 | + CollectionAssert.AreEqual(insert_values, select_values); |
521 | 479 | }
|
522 | 480 | }
|
523 | 481 | reader.Close();
|
@@ -768,12 +726,8 @@ public void BigArrayTest()
|
768 | 726 | if (!reader.IsDBNull(0))
|
769 | 727 | {
|
770 | 728 | int[] select_values = new int[insert_values.Length];
|
771 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
772 |
| - |
773 |
| - for (int i = 0; i < insert_values.Length; i++) |
774 |
| - { |
775 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
776 |
| - } |
| 729 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 730 | + CollectionAssert.AreEqual(insert_values, select_values); |
777 | 731 | }
|
778 | 732 | }
|
779 | 733 |
|
@@ -814,12 +768,8 @@ public void PartialUpdatesTest()
|
814 | 768 | if (!reader.IsDBNull(0))
|
815 | 769 | {
|
816 | 770 | int[] select_values = new int[insert_values.Length];
|
817 |
| - System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length); |
818 |
| - |
819 |
| - for (int i = 0; i < insert_values.Length; i++) |
820 |
| - { |
821 |
| - Assert.AreEqual(insert_values[i], select_values[i]); |
822 |
| - } |
| 771 | + Array.Copy((Array)reader.GetValue(0), select_values, select_values.Length); |
| 772 | + CollectionAssert.AreEqual(insert_values, select_values); |
823 | 773 | }
|
824 | 774 | }
|
825 | 775 |
|
|
0 commit comments