2 // OracleParameterTest.cs -
3 // NUnit Test Cases for OciDefineHandle
6 // Leszek Ciesielski <skolima@gmail.com>
8 // Copyright (C) 2006 Forcom (http://www.forcom.com.pl/)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using NUnit.Framework;
31 using System.Configuration;
32 using System.Globalization;
33 using System.Threading;
34 using System.Data.OracleClient;
38 namespace MonoTests.System.Data.OracleClient {
41 public class OciDefineHandleTest {
43 String connection_string;
44 OracleConnection connection;
45 OracleCommand command;
48 string test_value = " sim\u4FF5ply\u65E5 tri\u672Cm te\u4F00st ";
49 string test_value2 = " simply \u672Ctrim\u4F00 test in\u65E5 query \u4FF5 ";
52 public void FixtureSetUp ()
54 connection_string = Environment.GetEnvironmentVariable ("MONO_TESTS_ORACLE_CONNECTION_STRING");
55 if(connection_string == null)
56 Assert.Ignore ("Please consult README.tests.");
62 connection = new OracleConnection (connection_string);
64 using (command = connection.CreateCommand ()) {
67 "create table utf8test (id number(10), text nvarchar2(64), text2 nvarchar2(64) )";
68 command.ExecuteNonQuery ();
73 public void TearDown ()
75 using (command = connection.CreateCommand ()) {
76 command.CommandText = "drop table utf8test";
77 command.ExecuteNonQuery ();
81 connection.Dispose ();
84 [Test] // regression for bug #79004
85 public void TrimsUnicodeStringsTest ()
87 using (command = connection.CreateCommand ()) { // reusing command from SetUp causes parameter names mismatch
91 "insert into utf8test (id,text,text2) values (:id,:txt,'" + test_value2 + "')";
92 command.Parameters.Add (new OracleParameter ("ID", OracleType.Int32));
93 command.Parameters.Add( new OracleParameter ("TXT", OracleType.NVarChar));
94 command.Parameters ["ID"].Value = 101;
95 command.Parameters ["TXT"].Value = test_value;
96 command.ExecuteNonQuery ();
100 "select text,text2 from utf8test where id = 101";
101 command.Parameters.Clear ();
102 using (OracleDataReader reader = command.ExecuteReader ()) {
103 if (reader.Read ()) {
104 Assert.AreEqual (test_value, reader.GetString (0), "Passed through bind value mismatched");
105 Assert.AreEqual (test_value2, reader.GetString (1), "Directly passed value mismatched");
108 Assert.Fail ("Expected records not found.");