-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTester.NET5.cs
3753 lines (3561 loc) · 169 KB
/
Tester.NET5.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//------------------------------------------------------------------------------
// Odapter - a C# code generator for Oracle packages
// Copyright(C) 2021 Clay Lipscomb
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see<http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------
//#define SHORT_INTEGER // INTEGER as Int32
//#define DECIMAL_INTEGER // INTEGER as Decimal
#define DATE_TIME // DATE as DateTime
//#define SAFETYPE
//#define SAFETYPE_INTEGER // INTEGER as safe type OracleDecimal
//#define SAFETYPE_NUMBER // NUMBER as safe type OracleDecimal
//#define SAFETYPE_DATE // DATE as safe type OracleDate
//#define SAFETYPE_TIMESTAMP // TIMESTAMP as safe type OracleTimeStamp
//#define SAFETYPE_TIMESTAMP_TZ // TIMESTAMP WITH TIME ZONE as safe type OracleTimeStampTZ
//#define SAFETYPE_TIMESTAMP_LTZ // TIMESTAMP WITH TIME LOCAL ZONE as safe type OracleTimeStampLTZ
//#define SAFETYPE_BLOB // BLOB as safe type OracleBlob
//#define SAFETYPE_CLOB // CLOB, NCLOB as safe type OracleClob
#define ODPT_FILTER_PREFIX // "ODPT" as filter prefix of schema
#define MAPPING_FOR_TYPED_CURSOR // optional overloads for typed cursors methods are generated for mapping
//#define SEED_TABLES // seed all tables with test data
//#define LARGE_LOB_SIZE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Diagnostics;
using System.Threading.Tasks;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
#if SAFETYPE
using Schema.Odpt.Odpt.Safe;
using Schema.Odpt.Odpt.Safe.Package;
using Schema.Odpt.Odpt.Safe.Table;
using Schema.Odpt.Odpt.Safe.Type.Object;
using Schema.Odpt.Odpt.Safe.View;
#elif ODPT_FILTER_PREFIX
using Schema.Odpt.Odpt;
using Schema.Odpt.Odpt.Package;
using Schema.Odpt.Odpt.Table;
using Schema.Odpt.Odpt.Type.Object;
using Schema.Odpt.Odpt.View;
#else
using Schema.Odpt;
using Schema.Odpt.Package;
using Schema.Odpt.Table;
using Schema.Odpt.Type.Object;
using Schema.Odpt.View;
#endif
namespace Odapter.Tester.NET5 {
class Program {
static void Main(string[] args) {
Tester test = new Tester();
test.Run();
}
public class Tester {
private const uint TABLE_BIG_ROWS_TO_INSERT = 1000;
private const uint TABLE_BIG_ROWS_TO_RETRIEVE = 100;
// VARCHAR2, VARCHAR, NVARCHAR2, STRING
private const int MAX_STRING_SIZE_FOR_VARCHAR_ARG = 8191; // >= 8192 overflows against XE with managed
private const int MAX_STRING_SIZE_FOR_VARCHAR_IN_ASSOC_ARRAY = 4000;
private const int MAX_STRING_SIZE_FOR_NVARCHAR_IN_ASSOC_ARRAY = 1000;
private const int MAX_STRING_SIZE_FOR_CHAR = 2000;
private const int MAX_STRING_SIZE_FOR_CHAR_IN_ASSOC_ARRAY = 2000;
private const int MAX_STRING_SIZE_FOR_NCHAR_IN_ASSOC_ARRAY = 500;
private const int MAX_STRING_SIZE_FOR_VARCHAR_COL = 4000;
private const int MAX_STRING_SIZE_FOR_NVARCHAR_COL = 2000;
private const int MAX_STRING_SIZE_FOR_CHAR_COL = 2000;
private const int MAX_STRING_SIZE_FOR_NCHAR_COL = 1000;
private const int MAX_ASSOC_ARRAY_SIZE_OUT = UInt16.MaxValue;
private const int MAX_ASSOC_ARRAY_SIZE_IN = UInt16.MaxValue * 100;
// actual max of LOB *column* is 4 GB (4*1024*1024*1024-1 bytes) 4,294,967,295
private const int LOB_SIZE =
#if LARGE_LOB_SIZE
(100 * 1024 * 1024) - 1; // out of memory occurs at 1GB, will test at 0.1 GB
#else
(10 * 1024 * 1024) - 1; // faster tests with 0.01 GB
#endif
private const int MAX_BYTES_FOR_BLOB_COL = LOB_SIZE;
private const int MAX_STRING_SIZE_FOR_CLOB_COL = LOB_SIZE / 2; // allow for 2 bytes per String character
private const int MAX_STRING_SIZE_FOR_NCLOB_COL = LOB_SIZE / 2; // allow for 2 bytes per String character
private const Double MIN_BINARY_DOUBLE = 2.2250738585072014e-130d;
private const Double MAX_BINARY_DOUBLE = 1.7976931348623157e125d;
private const Decimal MAX_DECIMAL = 792281625142643375935439.5033M;
private const Decimal MIN_DECIMAL = -792281625142643375935439.5033M;
//792281625142643375935439 50335
//private const Decimal MAX_ORACLE_DECIMAL = 792281625142643375935439.5033M;
//private const Decimal MIN_ORACLE_DECIMAL = -792281625142643375935439.5033M;
//private readonly OracleDecimal MAX_ORACLE_DECIMAL = new OracleDecimal("999999999999999999999999999999999999990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
// 999999999999999999999999999999999999990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
internal void Run() {
Debug.Assert(Database.Instance.TestConnection());
#if SEED_TABLES
SeedTableBig();
SeedTableNumber();
#endif
TestStringCalls();
TestStringLobCalls();
TestByteArrayLobCalls();
TestInt32Calls();
TestInt64Calls();
TestDecimalCalls();
TestSingleCalls();
TestDoubleCalls();
TestDateCalls();
TestTimeSpanCalls();
TestCursorTypedTableBig();
TestCursorUntypedTableBig();
TestCursorTypedTableNumber();
TestCursorUntypedTableNumber();
TestCursorFilteredPackageTableBig();
TestAssociativeArrayInt64MaxCalls();
TestAssociativeArrayStringMaxCalls();
TestDuplicateSignatureCalls();
TestNoParamCalls();
TestOptionalParamCalls();
TestMiscCalls();
TestSingleton();
CompileTimeChecks();
//Console.WriteLine( "Complete." );
//Console.ReadLine();
}
#region Seeding Methods
private void SeedTableBig() {
OracleConnection conn =
#if SAFETYPE_BLOB || SAFETYPE_CLOB
Database.Instance.GetConnection(); // connection required to instantiate LOB classes
#else
null;
#endif
#if SAFETYPE_BLOB
OracleBlob oracleBlob = new OracleBlob(conn);
#endif
#if SAFETYPE_CLOB
OracleClob oracleClob = new OracleClob(conn);
OracleClob oracleNClob = new OracleClob(conn);
#endif
OdptPkgTableBig.Instance.TruncTable(null);
// misc values (zero, NaN, empty string, null)
#if SAFETYPE_BLOB
oracleBlob.Append(new byte[] { byte.MinValue }, 0, 1);
#endif
#if SAFETYPE_CLOB
oracleClob.Append(new char[] { ' ' }, 0, 1);
oracleNClob.Append(new char[] { ' ' }, 0, 1);
#endif
OdptPkgTableBig.Instance.InsertRow(0, 0, 0, 0, 0, 0, 0.0M, 0.0M, 0.0M, 0.0M, Single.NaN, Double.NaN, "", "", "", "", "", "", "", "", "", "",
null, null, null, null, null, null, null, null, null, null,
#if SAFETYPE_BLOB
oracleBlob,
#else
null,
#endif
#if SAFETYPE_CLOB
oracleClob,
#else
"",
#endif
#if SAFETYPE_CLOB
oracleNClob,
#else
"",
#endif
null, null, null, null, null, null, null, null, null,
conn);
// all explicitly null values
OdptPkgTableBig.Instance.InsertRow(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, conn);
// min values for INTEGER, NUMBER, DATE, TIMESTAMP, LOB
#if SAFETYPE_BLOB
oracleBlob.SetLength(0);
oracleBlob.Append(new byte[] { byte.MinValue }, 0, 1);
#endif
#if SAFETYPE_CLOB
oracleClob.SetLength(0);
oracleClob.Append(new char[] { 'F' }, 0, 1);
oracleNClob.SetLength(0);
oracleNClob.Append(new char[] { 'G' }, 0, 1);
#endif
// min values
OdptPkgTableBig.Instance.InsertRow(
#if SAFETYPE_INTEGER
OracleDecimal.MinValue, OracleDecimal.Truncate(OracleDecimal.MinValue, 0), OracleDecimal.Truncate(OracleDecimal.MinValue, 0), OracleDecimal.Truncate(OracleDecimal.MinValue, 0), OracleDecimal.Truncate(OracleDecimal.MinValue, 0), OracleDecimal.Truncate(OracleDecimal.MinValue, 0),
#elif DECIMAL_INTEGER
MIN_DECIMAL, MIN_DECIMAL, MIN_DECIMAL, MIN_DECIMAL, MIN_DECIMAL, MIN_DECIMAL,
#elif SHORT_INTEGER
Int32.MinValue, Int32.MinValue, Int32.MinValue, Int32.MinValue, Int32.MinValue, Int32.MinValue,
#else
Int64.MinValue, Int64.MinValue, Int64.MinValue, Int64.MinValue, Int64.MinValue, Int64.MinValue,
#endif
#if !SAFETYPE_NUMBER
MIN_DECIMAL, MIN_DECIMAL, MIN_DECIMAL, MIN_DECIMAL,
#else
OracleDecimal.MinValue, OracleDecimal.MinValue, OracleDecimal.MinValue, OracleDecimal.MinValue,
#endif
Single.MinValue, MIN_BINARY_DOUBLE,
"A", new string('?', MAX_STRING_SIZE_FOR_VARCHAR_COL), "B", new string('?', MAX_STRING_SIZE_FOR_VARCHAR_COL), "C", new string('?', MAX_STRING_SIZE_FOR_NVARCHAR_COL),
"D", new string('?', MAX_STRING_SIZE_FOR_CHAR_COL), "E", new string('?', MAX_STRING_SIZE_FOR_NCHAR_COL),
#if !SAFETYPE_DATE
DateTime.MinValue.AddMilliseconds(1),
#else
OracleDate.MinValue,
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.MinValue.AddMilliseconds(1),
#else
OracleTimeStamp.MinValue.AddMilliseconds(1),
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.MinValue.AddMilliseconds(1),
#else
OracleTimeStamp.MinValue.AddMilliseconds(1),
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.MinValue.AddMilliseconds(1),
#else
OracleTimeStamp.MinValue.AddMilliseconds(1),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.MinValue.AddMilliseconds(1),
#else
DateTimeOffset.MinValue.AddMilliseconds(1),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.MinValue.AddMilliseconds(1),
#else
DateTimeOffset.MinValue.AddMilliseconds(1),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.MinValue.AddMilliseconds(1),
#else
DateTimeOffset.MinValue.AddMilliseconds(1),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.MinValue.AddMilliseconds(1),
#else
DateTime.MinValue.AddMilliseconds(1),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.MinValue.AddMilliseconds(1),
#else
DateTime.MinValue.AddMilliseconds(1),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.MinValue.AddMilliseconds(1),
#else
DateTime.MinValue.AddMilliseconds(1),
#endif
#if !SAFETYPE_BLOB
new Byte[] { 0x00 },
#else
oracleBlob,
#endif
#if !SAFETYPE_CLOB
"F",
#else
oracleClob,
#endif
#if !SAFETYPE_CLOB
"G",
#else
oracleNClob,
#endif
null, null, null, null, null, null, null, null, null,
conn);
// max values
#if SAFETYPE_BLOB
oracleBlob.SetLength(0);
oracleBlob.Append(Enumerable.Repeat<byte>((byte)0x00, MAX_BYTES_FOR_BLOB_COL).ToArray(), 0, MAX_BYTES_FOR_BLOB_COL);
#endif
#if SAFETYPE_CLOB
oracleClob.SetLength(0);
oracleClob.Append(Enumerable.Repeat<char>('?', MAX_STRING_SIZE_FOR_CLOB_COL).ToArray(), 0, MAX_STRING_SIZE_FOR_CLOB_COL);
//Console.WriteLine("oracleClob.Length: " + oracleClob.Length);
oracleNClob.SetLength(0);
oracleNClob.Append(Enumerable.Repeat<char>('?', MAX_STRING_SIZE_FOR_NCLOB_COL).ToArray(), 0, MAX_STRING_SIZE_FOR_NCLOB_COL);
//Console.WriteLine("oracleNClob.Length: " + oracleNClob.Length);
#endif
OdptPkgTableBig.Instance.InsertRow(
#if SAFETYPE_INTEGER
OracleDecimal.MaxValue, OracleDecimal.Truncate(OracleDecimal.MaxValue, 0), OracleDecimal.Truncate(OracleDecimal.MaxValue, 0), OracleDecimal.Truncate(OracleDecimal.MaxValue, 0), OracleDecimal.Truncate(OracleDecimal.MaxValue, 0), OracleDecimal.Truncate(OracleDecimal.MaxValue, 0),
#elif DECIMAL_INTEGER
MAX_DECIMAL, MAX_DECIMAL, MAX_DECIMAL, MAX_DECIMAL, MAX_DECIMAL, MAX_DECIMAL,
#elif SHORT_INTEGER
Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue,
#else
Int64.MaxValue, Int64.MaxValue, Int64.MaxValue, Int64.MaxValue, Int64.MaxValue, Int64.MaxValue,
#endif
#if !SAFETYPE_NUMBER
MAX_DECIMAL, MAX_DECIMAL, MAX_DECIMAL, MAX_DECIMAL,
#else
OracleDecimal.MaxValue, OracleDecimal.MaxValue, OracleDecimal.MaxValue, OracleDecimal.MaxValue,
#endif
Single.MaxValue, MAX_BINARY_DOUBLE,
"A", new string('?', MAX_STRING_SIZE_FOR_VARCHAR_COL), "B", new string('?', MAX_STRING_SIZE_FOR_VARCHAR_COL), "C", new string('?', MAX_STRING_SIZE_FOR_NVARCHAR_COL),
"D", new string('?', MAX_STRING_SIZE_FOR_CHAR_COL), "E", new string('?', MAX_STRING_SIZE_FOR_NCHAR_COL),
#if !SAFETYPE_DATE
DateTime.MaxValue,
#else
OracleDate.MaxValue,
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.MaxValue.AddMilliseconds(-1), /* max value alone causes overflow when retrieved into .NET */
#else
OracleTimeStamp.MaxValue.AddMilliseconds(-1), /* max value alone causes overflow when retrieved into .NET */
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.MaxValue.AddSeconds(-1), /* max value alone causes overflow when retrieved into .NET TimeStamp(0) has no milliseconds */
#else
OracleTimeStamp.MaxValue.AddSeconds(-1), /* max value alone causes overflow when retrieved into .NET , TimeStamp(0) has no milliseconds */
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.MaxValue.AddMilliseconds(-1), /* max value alone causes overflow when retrieved into .NET */
#else
OracleTimeStamp.MaxValue.AddMilliseconds(-1), /* max value alone causes overflow when retrieved into .NET */
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.MaxValue.AddDays(-1),
#else
DateTimeOffset.MaxValue.AddDays(-1),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.MaxValue.AddDays(-1),
#else
DateTimeOffset.MaxValue.AddDays(-1),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.MaxValue.AddDays(-1),
#else
DateTimeOffset.MaxValue.AddDays(-1),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.MaxValue.AddDays(-1),
#else
DateTime.MaxValue.AddDays(-1),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.MaxValue.AddDays(-1),
#else
DateTime.MaxValue.AddDays(-1),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.MaxValue.AddDays(-1),
#else
DateTime.MaxValue.AddDays(-1),
#endif
#if !SAFETYPE_BLOB
Enumerable.Repeat((byte)0x00, MAX_BYTES_FOR_BLOB_COL).ToArray(),
#else
oracleBlob,
#endif
#if !SAFETYPE_CLOB
new string('?', MAX_STRING_SIZE_FOR_CLOB_COL),
#else
oracleClob,
#endif
#if !SAFETYPE_CLOB
new string('?', MAX_STRING_SIZE_FOR_NCLOB_COL),
#else
oracleNClob,
#endif
null, null, null, null, null, null, null, null, null,
conn);
// filler values
#if SAFETYPE_BLOB
oracleBlob.SetLength(0);
oracleBlob.Append(new Byte[] { 0x00 }, 0, 1);
#endif
#if SAFETYPE_CLOB
oracleClob.SetLength(0);
oracleClob.Append(new char[] { 'F' }, 0, 1);
oracleNClob.SetLength(0);
oracleNClob.Append(new char[] { 'G' }, 0, 1);
#endif
for (int i = 0; i < TABLE_BIG_ROWS_TO_INSERT; i++) {
OdptPkgTableBig.Instance.InsertRow(i + 1, i + 2, i + 3, i + 4,
i + 5, i + 6, i + 7, i + 8, i + 9, i + 10, i + 11, i + 12,
"A", new string('?', MAX_STRING_SIZE_FOR_VARCHAR_COL), "B", new string('?', MAX_STRING_SIZE_FOR_VARCHAR_COL), "C", new string('?', MAX_STRING_SIZE_FOR_NVARCHAR_COL),
"D", new string('?', MAX_STRING_SIZE_FOR_CHAR_COL), "E", new string('?', MAX_STRING_SIZE_FOR_NCHAR_COL),
#if !SAFETYPE_DATE
DateTime.Today.AddDays(i),
#else
new OracleDate(OracleDate.GetSysDate().Value.AddDays(i)),
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.Today.AddDays(i),
#else
OracleTimeStamp.GetSysDate().AddDays(i),
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.Today.AddDays(i),
#else
OracleTimeStamp.GetSysDate().AddDays(i),
#endif
#if !SAFETYPE_TIMESTAMP
DateTime.Today.AddDays(i),
#else
OracleTimeStamp.GetSysDate().AddDays(i),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.GetSysDate().AddDays(i),
#else
DateTimeOffset.UtcNow.AddDays(i),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.GetSysDate().AddDays(i),
#else
DateTimeOffset.UtcNow.AddDays(i),
#endif
#if SAFETYPE_TIMESTAMP_TZ
OracleTimeStampTZ.GetSysDate().AddDays(i),
#else
DateTimeOffset.UtcNow.AddDays(i),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.GetSysDate().AddDays(i),
#else
DateTime.Today.AddDays(i),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.GetSysDate().AddDays(i),
#else
DateTime.Today.AddDays(i),
#endif
#if SAFETYPE_TIMESTAMP_LTZ
OracleTimeStampLTZ.GetSysDate().AddDays(i),
#else
DateTime.Today.AddDays(i),
#endif
#if !SAFETYPE_BLOB
new Byte[] { 0x00 },
#else
oracleBlob,
#endif
#if !SAFETYPE_CLOB
"F",
#else
oracleClob,
#endif
#if !SAFETYPE_CLOB
"G",
#else
oracleNClob,
#endif
null, null, null, null, null, null, null, null, null,
conn);
}
#if SAFETYPE_BLOB
oracleBlob.Dispose();
#endif
#if SAFETYPE_CLOB
oracleClob.Dispose();
oracleNClob.Dispose();
#endif
if (conn != null) {
conn.Close();
conn.Dispose();
}
}
private void SeedTableNumber() {
OdptPkgTableNumber.Instance.TruncTable(null);
// all explicitly zero values
OdptPkgTableNumber.Instance.InsertRow(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null);
// all explictly null values
OdptPkgTableNumber.Instance.InsertRow(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null);
// min values
OdptPkgTableNumber.Instance.InsertRow(MIN_DECIMAL / 100000000,
-9, -99,
-999, -9999, -99999,
-Convert.ToInt32(new string('9', 6)), -Convert.ToInt32(new string('9', 7)), -Convert.ToInt32(new string('9', 8)), -Convert.ToInt32(new string('9', 9)),
#if SAFETYPE_INTEGER
-new OracleDecimal(new string('9', 10)), -new OracleDecimal(new string('9', 18)), -new OracleDecimal(new string('9', 19)), -new OracleDecimal(new string('9', 38)),
#elif DECIMAL_INTEGER
-Convert.ToDecimal(new string('9', 10)), -Convert.ToDecimal(new string('9', 18)), -Convert.ToDecimal(new string('9', 19)), MIN_DECIMAL,
#elif SHORT_INTEGER
Int32.MinValue, Int32.MinValue, Int32.MinValue, Int32.MinValue,
#else
-Convert.ToInt64(new string('9', 10)), -Convert.ToInt64(new string('9', 18)), Int64.MinValue, Int64.MinValue,
#endif
-9, -99,
-999, -9999, -99999, -Convert.ToInt32(new string('9', 9)),
#if SAFETYPE_INTEGER
-new OracleDecimal(new string('9', 10)), -new OracleDecimal(new string('9', 18)), -new OracleDecimal(new string('9', 19)), -new OracleDecimal(new string('9', 28)), -new OracleDecimal(new string('9', 29)), -new OracleDecimal(new string('9', 38)),
#elif DECIMAL_INTEGER
-Convert.ToDecimal(new string('9', 10)), -Convert.ToDecimal(new string('9', 18)), -Convert.ToDecimal(new string('9', 19)), MIN_DECIMAL, MIN_DECIMAL, MIN_DECIMAL,
#elif SHORT_INTEGER
Int32.MinValue, Int32.MinValue, Int32.MinValue, Int32.MinValue, Int32.MinValue, Int32.MinValue,
#else
-Convert.ToInt64(new string('9', 10)), -Convert.ToInt64(new string('9', 18)), Int64.MinValue, Int64.MinValue, Int64.MinValue, Int64.MinValue,
#endif
-9.9M, -99.999M, -Convert.ToDecimal(new string('9', 4) + "." + new string('9', 11)), /* 15.11 */ -Convert.ToDecimal(new string('9', 10) + "." + new string('8', 21)), /* 31.21 */
-Convert.ToDecimal(new string('9', 1) + "." + new string('8', 20)), /* 38.37 */ MIN_DECIMAL / 100000000, null);
// max values
OdptPkgTableNumber.Instance.InsertRow(MAX_DECIMAL, 9, 99, 999, 9999, 99999,
Convert.ToInt32(new string('9', 6)), Convert.ToInt32(new string('9', 7)), Convert.ToInt32(new string('9', 8)), Convert.ToInt32(new string('9', 9)),
#if SAFETYPE_INTEGER
new OracleDecimal(new string('9', 10)), new OracleDecimal(new string('9', 18)), new OracleDecimal(new string('9', 19)), new OracleDecimal(new string('9', 38)),
#elif DECIMAL_INTEGER
Convert.ToDecimal(new string('9', 10)), Convert.ToDecimal(new string('9', 18)), Convert.ToDecimal(new string('9', 19)), MAX_DECIMAL,
#elif SHORT_INTEGER
Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue,
#else
Convert.ToInt64(new string('9', 10)), Convert.ToInt64(new string('9', 18)), Int64.MaxValue, Int64.MaxValue,
#endif
9, 99, 999, 9999, 99999, Convert.ToInt32(new string('9', 9)),
#if SAFETYPE_INTEGER
new OracleDecimal(new string('9', 10)), new OracleDecimal(new string('9', 18)), new OracleDecimal(new string('9', 19)), new OracleDecimal(new string('9', 28)), new OracleDecimal(new string('9', 29)), new OracleDecimal(new string('9', 38)),
#elif DECIMAL_INTEGER
Convert.ToDecimal(new string('9', 10)), Convert.ToDecimal(new string('9', 18)), Convert.ToDecimal(new string('9', 19)), MAX_DECIMAL, MAX_DECIMAL, MAX_DECIMAL,
#elif SHORT_INTEGER
Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue,
#else
Convert.ToInt64(new string('9', 10)), Convert.ToInt64(new string('9', 18)), Int64.MaxValue, Int64.MaxValue, Int64.MaxValue, Int64.MaxValue,
#endif
9.9M, 99.999M, Convert.ToDecimal(new string('9', 4) + "." + new string('9', 11)), /* 15.11 */ Convert.ToDecimal(new string('9', 10) + "." + new string('8', 21)), /* 31.21 */
Convert.ToDecimal(new string('9', 1) + "." + new string('8', 20)), /* 38.37 */ MAX_DECIMAL, null);
}
#endregion Seeding
#region Cursors
//public List<T> TestCursorTypedStaticMappingRet<T>()
// where T : class, OdptPkgTableBig.ITTableBig, new() {
// uint? rowLimit = TABLE_BIG_ROWS_TO_RETRIEVE;
// List<T> retTableBigList = OdptPkgTableBig.Instance.GetRowsTypedRet<T>(rowLimit, null);
// return retTableBigList;
//}
private void TestCursorFilteredPackageTableBig() {
uint? rowLimit = TABLE_BIG_ROWS_TO_RETRIEVE;
#if ODPT_FILTER_PREFIX
ICollection<FilteredPkgTTableBigFiltered> retList, outList, outList2;
#else
ICollection<TTableBigFiltered> retList, outList, outList2;
#endif
DataTable retDataTable, outDataTable, outDataTable2;
retList = OdptPkgTableBig.Instance.GetRowsTypedFltrUsed<
#if ODPT_FILTER_PREFIX
FilteredPkgTTableBigFiltered
#else
TTableBigFiltered
#endif
>(out outList, out outList2, rowLimit, null);
Debug.Assert(retList.Count == rowLimit);
Debug.Assert(outList.Count == rowLimit);
Debug.Assert(outList2.Count == rowLimit);
retList = OdptPkgTableBig.Instance.GetRowsUntypedFltrUnused<
#if ODPT_FILTER_PREFIX
FilteredPkgTTableBigFiltered, FilteredPkgTTableBigFiltered, FilteredPkgTTableBigFiltered
#else
TTableBigFiltered, TTableBigFiltered, TTableBigFiltered
#endif
>(out outList, out outList2, false, false, rowLimit, null);
Debug.Assert(retList.Count == rowLimit);
Debug.Assert(outList.Count == rowLimit);
Debug.Assert(outList2.Count == rowLimit);
retDataTable = OdptPkgTableBig.Instance.GetRowsUntypedFltrUnused(out outDataTable, out outDataTable2, true, rowLimit, null);
Debug.Assert(retDataTable.Rows.Count == rowLimit);
Debug.Assert(outDataTable.Rows.Count == rowLimit);
Debug.Assert(outDataTable2.Rows.Count == rowLimit);
}
private void TestCursorTypedTableBig() {
uint? rowLimit = TABLE_BIG_ROWS_TO_RETRIEVE;
ICollection<TTableBig> retTableBigList, outTableBigList;
ICollection<TTableBigChar> outTableBigCharList;
// static, no mapping
// ret
retTableBigList = OdptPkgTableBig.Instance.GetRowsTypedRet<TTableBig>(rowLimit, null);
Debug.Assert(retTableBigList.Count == rowLimit);
// 1 out
OdptPkgTableBig.Instance.GetRowsTypedOut<TTableBig>(out outTableBigList, rowLimit, null);
Debug.Assert(outTableBigList.Count == rowLimit);
// ret and 1 out
retTableBigList = OdptPkgTableBig.Instance.GetRowsTypedOutRet<TTableBig>(out outTableBigList, rowLimit, null);
Debug.Assert(retTableBigList.Count == rowLimit && outTableBigList.Count == rowLimit);
// ret and 2 out
retTableBigList = OdptPkgTableBig.Instance.GetRowsTypedOut2Ret<TTableBig, TTableBigChar>(out outTableBigList, out outTableBigCharList, rowLimit, null);
Debug.Assert(retTableBigList.Count == rowLimit && outTableBigList.Count == rowLimit && outTableBigCharList.Count == rowLimit);
#if MAPPING_FOR_TYPED_CURSOR
// mapping
ICollection<TTableBigMapByPositionAll> retTableBigMapByPositionAllList, outTableBigMapByPositionAllList;
ICollection<TTableBigMapByPositionPartial> retTableBigMapByPositionPartialList, outTableBigMapByPositionPartialList;
ICollection<TTableBigCharMapByPositionAll> outTableBigCharMapByPositionAllList;
ICollection<TTableBigCharMapByPositionPartial> outTableBigCharMapByPositionPartialList;
// list ret - mapping by name
retTableBigList = OdptPkgTableBig.Instance.GetRowsTypedRet<TTableBig>(false, false, rowLimit, null);
// list ret - mapping by position, NOT allowing unmapped columns
retTableBigMapByPositionAllList = OdptPkgTableBig.Instance.GetRowsTypedRet<TTableBigMapByPositionAll>(true, false, rowLimit, null);
// list ret - mapping by position, allowing unmapped columns
retTableBigMapByPositionPartialList = OdptPkgTableBig.Instance.GetRowsTypedRet<TTableBigMapByPositionPartial>(true, true, rowLimit, null);
Debug.Assert(retTableBigList.Count == rowLimit && retTableBigMapByPositionAllList.Count == rowLimit && retTableBigMapByPositionPartialList.Count == rowLimit);
// all above cases using 1 out
outTableBigList = null; outTableBigMapByPositionAllList = null; outTableBigMapByPositionPartialList = null;
OdptPkgTableBig.Instance.GetRowsTypedOut<TTableBig>(out outTableBigList, false, false, rowLimit, null);
OdptPkgTableBig.Instance.GetRowsTypedOut<TTableBigMapByPositionAll>(out outTableBigMapByPositionAllList, true, false, rowLimit, null);
OdptPkgTableBig.Instance.GetRowsTypedOut<TTableBigMapByPositionPartial>(out outTableBigMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(outTableBigList.Count == rowLimit && outTableBigMapByPositionAllList.Count == rowLimit && outTableBigMapByPositionPartialList.Count == rowLimit);
// all above cases using ret and 1 out arg
outTableBigList = null; outTableBigMapByPositionAllList = null; outTableBigMapByPositionPartialList = null;
retTableBigList = OdptPkgTableBig.Instance.GetRowsTypedOutRet<TTableBig>(out outTableBigList, false, false, rowLimit, null);
retTableBigMapByPositionAllList = OdptPkgTableBig.Instance.GetRowsTypedOutRet<TTableBigMapByPositionAll>(out outTableBigMapByPositionAllList, true, false, rowLimit, null);
retTableBigMapByPositionPartialList = OdptPkgTableBig.Instance.GetRowsTypedOutRet<TTableBigMapByPositionPartial>(out outTableBigMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableBigList.Count == rowLimit && retTableBigMapByPositionAllList.Count == rowLimit && retTableBigMapByPositionPartialList.Count == rowLimit);
Debug.Assert(outTableBigList.Count == rowLimit && outTableBigMapByPositionAllList.Count == rowLimit && outTableBigMapByPositionPartialList.Count == rowLimit);
// all above cases using ret and 2 out args
outTableBigList = null; outTableBigMapByPositionAllList = null; outTableBigMapByPositionPartialList = null;
retTableBigList = OdptPkgTableBig.Instance.GetRowsTypedOut2Ret<TTableBig, TTableBigChar>(out outTableBigList, out outTableBigCharList, false, false, rowLimit, null);
retTableBigMapByPositionAllList = OdptPkgTableBig.Instance.GetRowsTypedOut2Ret<TTableBigMapByPositionAll, TTableBigCharMapByPositionAll>(out outTableBigMapByPositionAllList, out outTableBigCharMapByPositionAllList, true, false, rowLimit, null);
retTableBigMapByPositionPartialList = OdptPkgTableBig.Instance.GetRowsTypedOut2Ret<TTableBigMapByPositionPartial, TTableBigCharMapByPositionPartial>(out outTableBigMapByPositionPartialList, out outTableBigCharMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableBigList.Count == rowLimit && retTableBigMapByPositionAllList.Count == rowLimit && retTableBigMapByPositionPartialList.Count == rowLimit);
Debug.Assert(outTableBigList.Count == rowLimit && outTableBigMapByPositionAllList.Count == rowLimit && outTableBigMapByPositionPartialList.Count == rowLimit);
Debug.Assert(outTableBigCharList.Count == rowLimit && outTableBigCharMapByPositionAllList.Count == rowLimit && outTableBigCharMapByPositionPartialList.Count == rowLimit);
#endif
}
private void TestCursorTypedTableNumber() {
uint? rowLimit = null;
ICollection<TTableNumber> retTableNumberList, outTableNumberList;
ICollection<TTableNumberDec> outTableNumberDecList;
// static, no mapping
// ret
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsTypedRet<TTableNumber>(rowLimit, null);
Debug.Assert(retTableNumberList.Count > 0);
// 1 out
OdptPkgTableNumber.Instance.GetRowsTypedOut<TTableNumber>(out outTableNumberList, rowLimit, null);
Debug.Assert(outTableNumberList.Count > 0);
// ret and 1 out
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsTypedOutRet<TTableNumber>(out outTableNumberList, rowLimit, null);
Debug.Assert(retTableNumberList.Count > 0 && outTableNumberList.Count > 0);
// ret and 2 out
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsTypedOut2Ret<TTableNumber, TTableNumberDec>(out outTableNumberList, out outTableNumberDecList, rowLimit, null);
Debug.Assert(retTableNumberList.Count > 0 && outTableNumberList.Count > 0 && outTableNumberDecList.Count > 0);
#if MAPPING_FOR_TYPED_CURSOR
// mapping
ICollection<TTableNumberMapByPositionAll> retTableNumberMapByPositionAllList, outTableNumberMapByPositionAllList;
ICollection<TTableNumberMapByPositionPartial> retTableNumberMapByPositionPartialList, outTableNumberMapByPositionPartialList;
ICollection<TTableNumberDecMapByPositionAll> outTableNumberDecMapByPositionAllList;
ICollection<TTableNumberDecMapByPositionPartial> outTableNumberDecMapByPositionPartialList;
// list ret - mapping by name
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsTypedRet<TTableNumber>(false, false, rowLimit, null);
// list ret - mapping by position, NOT allowing unmapped columns
retTableNumberMapByPositionAllList = OdptPkgTableNumber.Instance.GetRowsTypedRet<TTableNumberMapByPositionAll>(true, false, rowLimit, null);
// list ret - mapping by position, allowing unmapped columns
retTableNumberMapByPositionPartialList = OdptPkgTableNumber.Instance.GetRowsTypedRet<TTableNumberMapByPositionPartial>(true, true, rowLimit, null);
Debug.Assert(retTableNumberList.Count > 0 && retTableNumberMapByPositionAllList.Count > 0 && retTableNumberMapByPositionPartialList.Count > 0);
// all above cases using 1 out
outTableNumberList = null; outTableNumberMapByPositionAllList = null; outTableNumberMapByPositionPartialList = null;
OdptPkgTableNumber.Instance.GetRowsTypedOut<TTableNumber>(out outTableNumberList, false, false, rowLimit, null);
OdptPkgTableNumber.Instance.GetRowsTypedOut<TTableNumberMapByPositionAll>(out outTableNumberMapByPositionAllList, true, false, rowLimit, null);
OdptPkgTableNumber.Instance.GetRowsTypedOut<TTableNumberMapByPositionPartial>(out outTableNumberMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(outTableNumberList.Count > 0 && outTableNumberMapByPositionAllList.Count > 0 && outTableNumberMapByPositionPartialList.Count > 0);
// all above cases using ret and 1 out arg
outTableNumberList = null; outTableNumberMapByPositionAllList = null; outTableNumberMapByPositionPartialList = null;
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsTypedOutRet<TTableNumber>(out outTableNumberList, false, false, rowLimit, null);
retTableNumberMapByPositionAllList = OdptPkgTableNumber.Instance.GetRowsTypedOutRet<TTableNumberMapByPositionAll>(out outTableNumberMapByPositionAllList, true, false, rowLimit, null);
retTableNumberMapByPositionPartialList = OdptPkgTableNumber.Instance.GetRowsTypedOutRet<TTableNumberMapByPositionPartial>(out outTableNumberMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableNumberList.Count > 0 && retTableNumberMapByPositionAllList.Count > 0 && retTableNumberMapByPositionPartialList.Count > 0);
Debug.Assert(outTableNumberList.Count > 0 && outTableNumberMapByPositionAllList.Count > 0 && outTableNumberMapByPositionPartialList.Count > 0);
// all above cases using ret and 2 out args
outTableNumberList = null; outTableNumberMapByPositionAllList = null; outTableNumberMapByPositionPartialList = null;
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsTypedOut2Ret<TTableNumber, TTableNumberDec>(out outTableNumberList, out outTableNumberDecList, false, false, rowLimit, null);
retTableNumberMapByPositionAllList = OdptPkgTableNumber.Instance.GetRowsTypedOut2Ret<TTableNumberMapByPositionAll, TTableNumberDecMapByPositionAll>(out outTableNumberMapByPositionAllList, out outTableNumberDecMapByPositionAllList, true, false, rowLimit, null);
retTableNumberMapByPositionPartialList = OdptPkgTableNumber.Instance.GetRowsTypedOut2Ret<TTableNumberMapByPositionPartial, TTableNumberDecMapByPositionPartial>(out outTableNumberMapByPositionPartialList, out outTableNumberDecMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableNumberList.Count > 0 && retTableNumberMapByPositionAllList.Count > 0 && retTableNumberMapByPositionPartialList.Count > 0);
Debug.Assert(outTableNumberList.Count > 0 && outTableNumberMapByPositionAllList.Count > 0 && outTableNumberMapByPositionPartialList.Count > 0);
Debug.Assert(outTableNumberDecList.Count > 0 && outTableNumberDecMapByPositionAllList.Count > 0 && outTableNumberDecMapByPositionPartialList.Count > 0);
#endif
}
private void TestCursorUntypedTableBig() {
uint? rowLimit = TABLE_BIG_ROWS_TO_RETRIEVE;
ICollection<TTableBigPositionalRecord> retTableBigList, outTableBigList;
ICollection<TTableBigMapByPositionAll> retTableBigMapByPositionAllList, outTableBigMapByPositionAllList;
ICollection<TTableBigMapByPositionPartial> retTableBigMapByPositionPartialList, outTableBigMapByPositionPartialList;
ICollection<TTableBigCharPositionalRecord> outTableBigCharList;
ICollection<TTableBigCharMapByPositionAll> outTableBigCharMapByPositionAllList;
ICollection<TTableBigCharMapByPositionPartial> outTableBigCharMapByPositionPartialList;
DataTable retTableBigDataTable, outTableBigDataTable, outTableBigDataTable2;
// DataTable ret
retTableBigDataTable = OdptPkgTableBig.Instance.GetRowsUntypedRet(true, rowLimit, null);
// list ret - mapping by name
retTableBigList = OdptPkgTableBig.Instance.GetRowsUntypedRet<TTableBigPositionalRecord>(false, false, rowLimit, null);
// list ret - mapping by position, NOT allowing unmapped columns
retTableBigMapByPositionAllList = OdptPkgTableBig.Instance.GetRowsUntypedRet<TTableBigMapByPositionAll>(true, false, rowLimit, null);
// list ret - mapping by position, allowing unmapped columns
retTableBigMapByPositionPartialList = OdptPkgTableBig.Instance.GetRowsUntypedRet<TTableBigMapByPositionPartial>(true, true, rowLimit, null);
Debug.Assert(retTableBigDataTable.Rows.Count == rowLimit && retTableBigList.Count == rowLimit && retTableBigMapByPositionAllList.Count == rowLimit && retTableBigMapByPositionPartialList.Count == rowLimit);
// all above cases using 1 out
outTableBigDataTable = null; outTableBigList = null; outTableBigMapByPositionAllList = null; outTableBigMapByPositionPartialList = null;
OdptPkgTableBig.Instance.GetRowsUntypedOut(out outTableBigDataTable, true, rowLimit, null);
OdptPkgTableBig.Instance.GetRowsUntypedOut<TTableBigPositionalRecord>(out outTableBigList, false, false, rowLimit, null);
OdptPkgTableBig.Instance.GetRowsUntypedOut<TTableBigMapByPositionAll>(out outTableBigMapByPositionAllList, true, false, rowLimit, null);
OdptPkgTableBig.Instance.GetRowsUntypedOut<TTableBigMapByPositionPartial>(out outTableBigMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(outTableBigDataTable.Rows.Count == rowLimit && outTableBigList.Count == rowLimit && outTableBigMapByPositionAllList.Count == rowLimit && outTableBigMapByPositionPartialList.Count == rowLimit);
// all above cases using ret and 1 out arg
outTableBigDataTable = null; outTableBigList = null; outTableBigMapByPositionAllList = null; outTableBigMapByPositionPartialList = null;
retTableBigDataTable = OdptPkgTableBig.Instance.GetRowsUntypedOutRet(out outTableBigDataTable, true, rowLimit, null);
retTableBigList = OdptPkgTableBig.Instance.GetRowsUntypedOutRet<TTableBigPositionalRecord, TTableBigPositionalRecord>(out outTableBigList, false, false, rowLimit, null);
retTableBigMapByPositionAllList = OdptPkgTableBig.Instance.GetRowsUntypedOutRet<TTableBigMapByPositionAll, TTableBigMapByPositionAll>(out outTableBigMapByPositionAllList, true, false, rowLimit, null);
retTableBigMapByPositionPartialList = OdptPkgTableBig.Instance.GetRowsUntypedOutRet<TTableBigMapByPositionPartial, TTableBigMapByPositionPartial>(out outTableBigMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableBigDataTable.Rows.Count == rowLimit && retTableBigList.Count == rowLimit && retTableBigMapByPositionAllList.Count == rowLimit && retTableBigMapByPositionPartialList.Count == rowLimit);
Debug.Assert(outTableBigDataTable.Rows.Count == rowLimit && outTableBigList.Count == rowLimit && outTableBigMapByPositionAllList.Count == rowLimit && outTableBigMapByPositionPartialList.Count == rowLimit);
// all above cases using ret and 2 out args
outTableBigDataTable = null; outTableBigList = null; outTableBigMapByPositionAllList = null; outTableBigMapByPositionPartialList = null;
retTableBigDataTable = OdptPkgTableBig.Instance.GetRowsUntypedOut2Ret(out outTableBigDataTable, out outTableBigDataTable2, true, rowLimit, null);
retTableBigList = OdptPkgTableBig.Instance.GetRowsUntypedOut2Ret<TTableBigPositionalRecord, TTableBigPositionalRecord, TTableBigCharPositionalRecord>(out outTableBigList, out outTableBigCharList, false, false, rowLimit, null);
retTableBigMapByPositionAllList = OdptPkgTableBig.Instance.GetRowsUntypedOut2Ret<TTableBigMapByPositionAll, TTableBigMapByPositionAll, TTableBigCharMapByPositionAll>(out outTableBigMapByPositionAllList, out outTableBigCharMapByPositionAllList, true, false, rowLimit, null);
retTableBigMapByPositionPartialList = OdptPkgTableBig.Instance.GetRowsUntypedOut2Ret<TTableBigMapByPositionPartial, TTableBigMapByPositionPartial, TTableBigCharMapByPositionPartial>(out outTableBigMapByPositionPartialList, out outTableBigCharMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableBigDataTable.Rows.Count == rowLimit && retTableBigList.Count == rowLimit && retTableBigMapByPositionAllList.Count == rowLimit && retTableBigMapByPositionPartialList.Count == rowLimit);
Debug.Assert(outTableBigDataTable.Rows.Count == rowLimit && outTableBigList.Count == rowLimit && outTableBigMapByPositionAllList.Count == rowLimit && outTableBigMapByPositionPartialList.Count == rowLimit);
Debug.Assert(outTableBigDataTable2.Rows.Count == rowLimit && outTableBigCharList.Count == rowLimit && outTableBigCharMapByPositionAllList.Count == rowLimit && outTableBigCharMapByPositionPartialList.Count == rowLimit);
}
private void TestCursorUntypedTableNumber() {
uint? rowLimit = null;
ICollection<TTableNumberPositionalRecord> retTableNumberList, outTableNumberList;
ICollection<TTableNumberMapByPositionAll> retTableNumberMapByPositionAllList, outTableNumberMapByPositionAllList;
ICollection<TTableNumberMapByPositionPartial> retTableNumberMapByPositionPartialList, outTableNumberMapByPositionPartialList;
ICollection<TTableNumberDecPositionalRecord> outTableNumberDecList;
ICollection<TTableNumberDecMapByPositionAll> outTableNumberDecMapByPositionAllList;
ICollection<TTableNumberDecMapByPositionPartial> outTableNumberDecMapByPositionPartialList;
DataTable retTableNumberDataTable, outTableNumberDataTable, outTableNumberDataTable2;
// DataTable ret
retTableNumberDataTable = OdptPkgTableNumber.Instance.GetRowsUntypedRet(true, rowLimit, null);
// list ret - mapping by name
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsUntypedRet<TTableNumberPositionalRecord>(false, false, rowLimit, null);
// list ret - mapping by position, NOT allowing unmapped columns
retTableNumberMapByPositionAllList = OdptPkgTableNumber.Instance.GetRowsUntypedRet<TTableNumberMapByPositionAll>(true, false, rowLimit, null);
// list ret - mapping by position, allowing unmapped columns
retTableNumberMapByPositionPartialList = OdptPkgTableNumber.Instance.GetRowsUntypedRet<TTableNumberMapByPositionPartial>(true, true, rowLimit, null);
Debug.Assert(retTableNumberDataTable.Rows.Count > 0 && retTableNumberList.Count > 0 && retTableNumberMapByPositionAllList.Count > 0 && retTableNumberMapByPositionPartialList.Count > 0);
// all above cases using 1 out
outTableNumberDataTable = null; outTableNumberList = null; outTableNumberMapByPositionAllList = null; outTableNumberMapByPositionPartialList = null;
OdptPkgTableNumber.Instance.GetRowsUntypedOut(out outTableNumberDataTable, true, rowLimit, null);
OdptPkgTableNumber.Instance.GetRowsUntypedOut<TTableNumberPositionalRecord>(out outTableNumberList, false, false, rowLimit, null);
OdptPkgTableNumber.Instance.GetRowsUntypedOut<TTableNumberMapByPositionAll>(out outTableNumberMapByPositionAllList, true, false, rowLimit, null);
OdptPkgTableNumber.Instance.GetRowsUntypedOut<TTableNumberMapByPositionPartial>(out outTableNumberMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(outTableNumberDataTable.Rows.Count > 0 && outTableNumberList.Count > 0 && outTableNumberMapByPositionAllList.Count > 0 && outTableNumberMapByPositionPartialList.Count > 0);
// all above cases using ret and 1 out arg
outTableNumberDataTable = null; outTableNumberList = null; outTableNumberMapByPositionAllList = null; outTableNumberMapByPositionPartialList = null;
retTableNumberDataTable = OdptPkgTableNumber.Instance.GetRowsUntypedOutRet(out outTableNumberDataTable, true, rowLimit, null);
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsUntypedOutRet<TTableNumberPositionalRecord, TTableNumberPositionalRecord>(out outTableNumberList, false, false, rowLimit, null);
retTableNumberMapByPositionAllList = OdptPkgTableNumber.Instance.GetRowsUntypedOutRet<TTableNumberMapByPositionAll, TTableNumberMapByPositionAll>(out outTableNumberMapByPositionAllList, true, false, rowLimit, null);
retTableNumberMapByPositionPartialList = OdptPkgTableNumber.Instance.GetRowsUntypedOutRet<TTableNumberMapByPositionPartial, TTableNumberMapByPositionPartial>(out outTableNumberMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableNumberDataTable.Rows.Count > 0 && retTableNumberList.Count > 0 && retTableNumberMapByPositionAllList.Count > 0 && retTableNumberMapByPositionPartialList.Count > 0);
Debug.Assert(outTableNumberDataTable.Rows.Count > 0 && outTableNumberList.Count > 0 && outTableNumberMapByPositionAllList.Count > 0 && outTableNumberMapByPositionPartialList.Count > 0);
// all above cases using ret and 2 out args
outTableNumberDataTable = null; outTableNumberList = null; outTableNumberMapByPositionAllList = null; outTableNumberMapByPositionPartialList = null;
retTableNumberDataTable = OdptPkgTableNumber.Instance.GetRowsUntypedOut2Ret(out outTableNumberDataTable, out outTableNumberDataTable2, true, rowLimit, null);
retTableNumberList = OdptPkgTableNumber.Instance.GetRowsUntypedOut2Ret<TTableNumberPositionalRecord, TTableNumberPositionalRecord, TTableNumberDecPositionalRecord>(out outTableNumberList, out outTableNumberDecList, false, false, rowLimit, null);
retTableNumberMapByPositionAllList = OdptPkgTableNumber.Instance.GetRowsUntypedOut2Ret<TTableNumberMapByPositionAll, TTableNumberMapByPositionAll, TTableNumberDecMapByPositionAll>(out outTableNumberMapByPositionAllList, out outTableNumberDecMapByPositionAllList, true, false, rowLimit, null);
retTableNumberMapByPositionPartialList = OdptPkgTableNumber.Instance.GetRowsUntypedOut2Ret<TTableNumberMapByPositionPartial, TTableNumberMapByPositionPartial, TTableNumberDecMapByPositionPartial>(out outTableNumberMapByPositionPartialList, out outTableNumberDecMapByPositionPartialList, true, true, rowLimit, null);
Debug.Assert(retTableNumberDataTable.Rows.Count > 0 && retTableNumberList.Count > 0 && retTableNumberMapByPositionAllList.Count > 0 && retTableNumberMapByPositionPartialList.Count > 0);
Debug.Assert(outTableNumberDataTable.Rows.Count > 0 && outTableNumberList.Count > 0 && outTableNumberMapByPositionAllList.Count > 0 && outTableNumberMapByPositionPartialList.Count > 0);
Debug.Assert(outTableNumberDataTable2.Rows.Count > 0 && outTableNumberDecList.Count > 0 && outTableNumberDecMapByPositionAllList.Count > 0 && outTableNumberDecMapByPositionPartialList.Count > 0);
}
#endregion
#region Tests for isolated data types (built-ins, ODP.NET SafeTypes, etc.) and respective associative arrays
/// <summary>
/// Test use of Int32
/// </summary>
private void TestInt32Calls() {
Int32? pInInt = 0, pInOutInt = 0, pOutInt, retInt;
IList<Int32?> pInListInt = new List<Int32?>(), pInOutListInt = new List<Int32?>(), pOutListInt = new List<Int32?>();
IList<Int32?> intTestValues = new List<Int32?>() { Int32.MaxValue, Int32.MinValue, 0, null };
// BINARY_INTEGER and equivalents
// BINARY_INTEGER
// standard call
foreach (Int32? it in intTestValues) {
pInInt = pInOutInt = it;
retInt = OdptPkgMain.Instance.FuncBinaryInteger(pInInt, ref pInOutInt, out pOutInt, null);
Debug.Assert(pInInt.Equals(pInOutInt) && pInInt.Equals(pOutInt) && pInInt.Equals(retInt));
}
// PLS_INTEGER
// standard call
foreach (Int32? it in intTestValues) {
pInInt = pInOutInt = it;
retInt = OdptPkgMain.Instance.FuncPlsInteger(pInInt, ref pInOutInt, out pOutInt, null);
Debug.Assert(pInInt.Equals(pInOutInt) && pInInt.Equals(pOutInt) && pInInt.Equals(retInt));
}
// NATURAL, POSITIVE
foreach (Int32? it in new List<Int32?>() { Int32.MaxValue, 0, null }) { // exclude negative values for test
pInInt = pInOutInt = it;
retInt = OdptPkgMain.Instance.FuncNatural(pInInt, ref pInOutInt, out pOutInt, null);
Debug.Assert(pInInt.Equals(pInOutInt) && pInInt.Equals(pOutInt) && pInInt.Equals(retInt));
}
foreach (Int32? it in new List<Int32?>() { Int32.MaxValue, null }) { // exclude non-positive values for test
pInInt = pInOutInt = it;
retInt = OdptPkgMain.Instance.FuncPositive(pInInt, ref pInOutInt, out pOutInt, null);
Debug.Assert(pInInt.Equals(pInOutInt) && pInInt.Equals(pOutInt) && pInInt.Equals(retInt));
}
// NATURALN, POSITIVEN - functions are failing in package regardless of value
foreach (Int32? it in new List<Int32?>() { Int32.MaxValue, 0 }) { // exclude negative and null values for test
pInInt = pInOutInt = it;
//retInt = OdptPkgMain.Instance.FuncNaturaln(pInInt, ref pInOutInt, out pOutInt, null);
//Debug.Assert(pInInt.Equals(pInOutInt) && pInInt.Equals(pOutInt) && pInInt.Equals(retInt));
}
foreach (Int32? it in new List<Int32?>() { Int32.MaxValue }) { // exclude non-positive and null values for test
pInInt = pInOutInt = it;
//retInt = OdptPkgMain.Instance.FuncPositiven(pInInt, ref pInOutInt, out pOutInt, null);
//Debug.Assert(pInInt.Equals(pInOutInt) && pInInt.Equals(pOutInt) && pInInt.Equals(retInt));
}
// binding an associative array of BINARY_INTEGER and PLS_INTEGER or their subtypes is not suported by ODP.NET
}
/// <summary>
/// Test use of Int64
/// </summary>
private void TestInt64Calls() {
#if SAFETYPE_INTEGER
OracleDecimal? pIn, pInOut, pOut, ret;
IList<OracleDecimal?> pInList = new List<OracleDecimal?>(), pInOutList = new List<OracleDecimal?>(), pOutList = new List<OracleDecimal?>(), retList;
IList<OracleDecimal?> testValues = new List<OracleDecimal?>() { OracleDecimal.Truncate(OracleDecimal.MaxValue, 0), OracleDecimal.Truncate(OracleDecimal.MinValue, 0), 0, OracleDecimal.Null };
#elif DECIMAL_INTEGER
Decimal? pIn, pInOut, pOut, ret;
IList<Decimal?> pInList = new List<Decimal?>(), pInOutList = new List<Decimal?>(), pOutList = new List<Decimal?>(), retList;
IList<Decimal?> testValues = new List<Decimal?>() { MAX_DECIMAL, MIN_DECIMAL, 0, null };
#elif SHORT_INTEGER
Int32? pIn, pInOut, pOut, ret;
IList<Int32?> pInList = new List<Int32?>(), pInOutList = new List<Int32?>(), pOutList = new List<Int32?>(), retList;
IList<Int32?> testValues = new List<Int32?>() { Int32.MaxValue, Int32.MinValue, 0, null };
#else
Int64? pIn, pInOut, pOut, ret;
IList<Int64?> pInList = new List<Int64?>(), pInOutList = new List<Int64?>(), pOutList = new List<Int64?>(), retList;
IList<Int64?> testValues = new List<Int64?>() { Int64.MaxValue, Int64.MinValue, 0, null };
#endif
// INTEGER and equivalents
// INTEGER
// standard call
for (int i = 0; i < testValues.Count; i++) {
pIn = testValues[i]; pInOut = null;
ret = OdptPkgMain.Instance.FuncInteger(pIn, ref pInOut, out pOut, null);
Debug.Assert(pIn.Equals(pInOut) && pIn.Equals(pOut) && pIn.Equals(ret));
}
// assoc array (INTEGER indexed)
pInList = pInOutList = testValues;
retList = OdptPkgMain.Instance.FuncAaInteger(pInList, ref pInOutList, out pOutList, null);
for (int i = 0; i < pInList.Count; i++) Debug.Assert(pInList[i].Equals(pInOutList[i]));
for (int i = 0; i < pInList.Count; i++) Debug.Assert(pInList[i].Equals(pOutList[i]));
for (int i = 0; i < pInList.Count; i++) Debug.Assert(pInList[i].Equals(retList[i]));
// VARCHAR2 indexed associative array will not execute successfully due to limiation of ODP.NET
//pInList = testValues;
//pInOutList = testValues;
//retList = OdptPkgMain.Instance.FuncAaIntegerV(pInList, ref pInOutList, out pOutList, null);
//for (int i = 0; i < pInList.Count; i++) if (!pInList[i].Equals(pInOutList[i])) throw new Exception("Error");
//for (int i = 0; i < pInList.Count; i++) if (!pInList[i].Equals(pOutList[i])) throw new Exception("Error");
//for (int i = 0; i < pInList.Count; i++) if (!pInList[i].Equals(retList[i])) throw new Exception("Error");
// INT
// stanard call
for (int i = 0; i < testValues.Count; i++) {
pIn = testValues[i]; pInOut = null;
ret = OdptPkgMain.Instance.FuncInt(pIn, ref pInOut, out pOut, null);
Debug.Assert(pIn.Equals(pInOut) && pIn.Equals(pOut) && pIn.Equals(ret));
}
// SMALLINT
// standard call
for (int i = 0; i < testValues.Count; i++) {
pIn = testValues[i]; pInOut = null;
ret = OdptPkgMain.Instance.FuncSmallint(pIn, ref pInOut, out pOut, null);
Debug.Assert(pIn.Equals(pInOut) && pIn.Equals(pOut) && pIn.Equals(ret));
}
// assoc array
pInList = pInOutList = testValues;
retList = OdptPkgMain.Instance.FuncAaSmallint(pInList, ref pInOutList, out pOutList, null);
for (int i = 0; i < pInList.Count; i++) {
Debug.Assert(pInList[i].Equals(pInOutList[i]));
Debug.Assert(pInList[i].Equals(pOutList[i]));
Debug.Assert(pInList[i].Equals(retList[i]));
}
// DECIMAL
// standard call
for (int i = 0; i < testValues.Count; i++) {
pIn = testValues[i]; pInOut = null;
ret = OdptPkgMain.Instance.FuncDecimal(pIn, ref pInOut, out pOut, null);
Debug.Assert(pIn.Equals(pInOut) && pIn.Equals(pOut) && pIn.Equals(ret));
}
// assoc array
pInList = pInOutList = testValues;
retList = OdptPkgMain.Instance.FuncAaDecimal(pInList, ref pInOutList, out pOutList, null);
for (int i = 0; i < pInList.Count; i++) Debug.Assert(pInList[i].Equals(pInOutList[i]));
for (int i = 0; i < pInList.Count; i++) Debug.Assert(pInList[i].Equals(pOutList[i]));
for (int i = 0; i < pInList.Count; i++) Debug.Assert(pInList[i].Equals(retList[i]));
// NUMERIC
// standard call
for (int i = 0; i < testValues.Count; i++) {
pIn = testValues[i]; pInOut = null;
ret = OdptPkgMain.Instance.FuncNumeric(pIn, ref pInOut, out pOut, null);
Debug.Assert(pIn.Equals(pInOut) && pIn.Equals(pOut) && pIn.Equals(ret));
}
// assoc array
pInList = pInOutList = testValues;
retList = OdptPkgMain.Instance.FuncAaNumeric(pInList, ref pInOutList, out pOutList, null);
for (int i = 0; i < pInList.Count; i++) Debug.Assert(pInList[i].Equals(pInOutList[i]));