~ubuntu-branches/ubuntu/lucid/mono/lucid

« back to all changes in this revision

Viewing changes to mcs/class/System.Data.OracleClient/Test/System.Data.OracleClient/OracleParameterTest.cs

  • Committer: Bazaar Package Importer
  • Author(s): Mirco Bauer
  • Date: 2009-07-30 19:35:10 UTC
  • mto: (5.2.2 squeeze)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090730193510-cdttfvqokq2kmdvh
Tags: upstream-2.4.2.3+dfsg
ImportĀ upstreamĀ versionĀ 2.4.2.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
                }
129
129
 
130
130
                [Test] // ctor ()
131
 
#if NET_2_0
132
 
                [Category ("NotWorking")] // #A8 fails
133
 
#endif
134
131
                public void Constructor2 ()
135
132
                {
136
133
                        OracleParameter param;
163
160
                        Assert.AreEqual (string.Empty, param.ParameterName, "#B5");
164
161
                        Assert.AreEqual ((byte) 0, param.Precision, "#B6");
165
162
                        Assert.AreEqual ((byte) 0, param.Scale, "#B7");
 
163
#if NET_2_0
 
164
                        Assert.AreEqual (7, param.Size, "#B8");
 
165
#else
166
166
                        Assert.AreEqual (0, param.Size, "#B8");
 
167
#endif
167
168
                        Assert.AreEqual (string.Empty, param.SourceColumn, "#B9");
168
169
#if NET_2_0
169
170
                        Assert.IsFalse (param.SourceColumnNullMapping, "#B10");
369
370
                                        "Unexpected result value.");
370
371
                        }
371
372
                }
 
373
 
 
374
                private void ParamSize_SPCreation_ValueInsertion (OracleConnection conn)
 
375
                {
 
376
                    string createSP =
 
377
                        "CREATE OR REPLACE PROCEDURE GetTextValue \n" +
 
378
                        "( \n" +
 
379
                        "id IN Number(10),\n" +
 
380
                        "text OUT varchar2(64) \n" +
 
381
                        ")\n" +
 
382
                        "AS\n" +
 
383
                        "BEGIN\n" +
 
384
                        "SELECT oratest.text INTO text \n" +
 
385
                        "  FROM oratest\n" +
 
386
                        "  WHERE oratest.id = id; \n" +
 
387
                        "END;\n";
 
388
 
 
389
                    string insertValue = "INSERT INTO oratest VALUES " +
 
390
                        "(424908, \"This is a test for 424908 parameter size bug\", NULL);";
 
391
 
 
392
                    using (command = conn.CreateCommand ()) {
 
393
                        command.CommandText = createSP;
 
394
                        command.CommandType = CommandType.Text;
 
395
                        command.ExecuteNonQuery ();
 
396
 
 
397
                        command.CommandText = insertValue;
 
398
                        command.ExecuteNonQuery ();
 
399
 
 
400
                        command.CommandText = "commit";
 
401
                        command.ExecuteNonQuery ();
 
402
                    }
 
403
                }
 
404
 
 
405
                [Test]
 
406
                [Category("NotWorking")]
 
407
                public void ParamSize_424908_ValueError ()
 
408
                {
 
409
                    //OracleConnection conn = new OracleConnection (connection_string);
 
410
                    //conn.Open ();
 
411
 
 
412
                    ParamSize_SPCreation_ValueInsertion (connection);
 
413
 
 
414
                    using (command = connection.CreateCommand ()) {
 
415
                        
 
416
                        OracleParameter id = new OracleParameter ();
 
417
                        id.ParameterName = "id";
 
418
                        id.OracleType = OracleType.Number;
 
419
                        id.Direction = ParameterDirection.Input;
 
420
                        id.Value = 424908;
 
421
                        command.Parameters.Add (id);
 
422
 
 
423
                        OracleParameter text = new OracleParameter ();
 
424
                        text.ParameterName = "text";                                                                    
 
425
                        text.OracleType = OracleType.NVarChar;                                                                  
 
426
                        text.Direction = ParameterDirection.Output;
 
427
                        text.Value = string.Empty;
 
428
                        text.Size = 64;
 
429
                        command.Parameters.Add (text);
 
430
 
 
431
                        try {
 
432
                            command.CommandType = CommandType.StoredProcedure;
 
433
                            command.CommandText = "GetTextValue";
 
434
                            command.ExecuteNonQuery ();
 
435
                            Assert.Fail ("Expected OracleException not occurred!");
 
436
                        } catch (OracleException ex) {
 
437
                            Assert.AreEqual ("6502", ex.Code, "Error code mismatch");
 
438
                            connection.Close ();
 
439
                        }
 
440
                    }
 
441
                }
 
442
 
 
443
                [Test]
 
444
                [Category("NotWorking")]
 
445
                public void ParamSize_424908_ConstructorSizeSetTest ()
 
446
                {
 
447
                    //OracleConnection conn = new OracleConnection (connection_string);
 
448
                    //conn.Open ();
 
449
 
 
450
                    ParamSize_SPCreation_ValueInsertion (connection);
 
451
 
 
452
                    using (command = connection.CreateCommand ()) {
 
453
                        OracleParameter id = new OracleParameter ();
 
454
                        id.ParameterName = "id";
 
455
                        id.OracleType = OracleType.Number;
 
456
                        id.Direction = ParameterDirection.Input;
 
457
                        id.Value = 424908;
 
458
                        command.Parameters.Add (id);
 
459
 
 
460
                        OracleParameter text = new OracleParameter ("text", OracleType.NVarChar, 64);
 
461
                        text.Direction = ParameterDirection.Output;
 
462
                        text.Value = string.Empty;
 
463
                        command.Parameters.Add (text);
 
464
 
 
465
                        command.CommandType = CommandType.StoredProcedure;
 
466
                        command.CommandText = "GetTextValue";
 
467
                        command.ExecuteNonQuery ();
 
468
 
 
469
                        Assert.AreEqual ("This is a test for 424908 parameter size bug", text.Value, "OracleParameter value mismatch");
 
470
                    }
 
471
                }
 
472
 
 
473
                [Test]
 
474
                [Category("NotWorking")]
 
475
                public void ParamSize_424908_SizeNotSetError ()
 
476
                {
 
477
 
 
478
                    ParamSize_SPCreation_ValueInsertion (connection);
 
479
 
 
480
                    using (command = connection.CreateCommand ()) {
 
481
                        OracleParameter id = new OracleParameter ();
 
482
                        id.ParameterName = "id";
 
483
                        id.OracleType = OracleType.Number;
 
484
                        id.Direction = ParameterDirection.Input;
 
485
                        id.Value = 424908;
 
486
                        command.Parameters.Add (id);
 
487
 
 
488
                        OracleParameter text = new OracleParameter ();
 
489
                        text.ParameterName = "text";                                                                    
 
490
                        text.OracleType = OracleType.NVarChar;                                                                  
 
491
                        text.Direction = ParameterDirection.Output;
 
492
                        text.Value = DBNull.Value;
 
493
                        command.Parameters.Add (text);
 
494
 
 
495
                        try {
 
496
                            command.CommandType = CommandType.StoredProcedure;
 
497
                            command.CommandText = "GetTextValue";
 
498
                            command.ExecuteNonQuery ();
 
499
                            Assert.Fail ("Expected System.Exception not occurred!");
 
500
                        } catch (Exception ex) {
 
501
                            Assert.AreEqual ("Size must be set.", ex.Message, "Exception mismatch");
 
502
                        }                   
 
503
                    }
 
504
                }
372
505
        }
373
506
}