Author: gert
Date: 2007-10-19 14:03:47 -0400 (Fri, 19 Oct 2007)
New Revision: 87839

Added:
   trunk/gert/standalone/bug335329/
   trunk/gert/standalone/bug335329/default.build
   trunk/gert/standalone/bug335329/test.cs
Modified:
   trunk/gert/standalone/known-issues
Log:
Added test for bug #335329.


Added: trunk/gert/standalone/bug335329/default.build
===================================================================
--- trunk/gert/standalone/bug335329/default.build       2007-10-19 17:33:20 UTC 
(rev 87838)
+++ trunk/gert/standalone/bug335329/default.build       2007-10-19 18:03:47 UTC 
(rev 87839)
@@ -0,0 +1,62 @@
+<project name="bug335329" default="rebuild">
+       <target name="mono-1.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,ONLY_1_1,MONO" />
+       </target>
+
+       <target name="mono-2.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,NET_2_0,ONLY_2_0,MONO" />
+       </target>
+
+       <target name="net-1.1">
+               <property name="csc.defines" value="NET_1_0,NET_1_1,ONLY_1_1" />
+       </target>
+
+       <target name="net-2.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,NET_2_0,ONLY_2_0" />
+       </target>
+
+       <property name="frameworks" value="mono-1.0,mono-2.0,net-1.1,net-2.0" />
+
+       <target name="clean">
+               <delete>
+                       <fileset>
+                               <include name="out" />
+                               <include name="test.exe" />
+                       </fileset>
+               </delete>
+       </target>
+
+       <target name="build">
+               <property name="original.targetframework" 
value="${nant.settings.currentframework}" />
+
+               <foreach property="framework" item="String" in="${frameworks}" 
delim=",">
+                       <if test="${framework::exists(framework)}">
+                               <property name="nant.settings.currentframework" 
value="${framework}" />
+                               <call 
target="${nant.settings.currentframework}" />
+                               <call target="run" />
+                               <call target="clean" />
+                       </if>
+               </foreach>
+
+               <property name="nant.settings.currentframework" 
value="${original.targetframework}" />
+       </target>
+
+       <target name="compile">
+               <csc target="exe" output="test.exe" define="${csc.defines}" 
warnaserror="true" warninglevel="4">
+                       <sources>
+                               <include name="../../build/common/Assert.cs" />
+                               <include name="test.cs" />
+                       </sources>
+                       <references>
+                               <include name="System.Data.dll" />
+                       </references>
+               </csc>
+       </target>
+
+       <target name="run" depends="compile">
+               <exec program="test.exe" managed="true" output="out" />
+               <fail if="${file::exists('out')}" />
+       </target>
+
+       <target name="rebuild" depends="clean, build" />
+</project>


Property changes on: trunk/gert/standalone/bug335329/default.build
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/gert/standalone/bug335329/test.cs
===================================================================
--- trunk/gert/standalone/bug335329/test.cs     2007-10-19 17:33:20 UTC (rev 
87838)
+++ trunk/gert/standalone/bug335329/test.cs     2007-10-19 18:03:47 UTC (rev 
87839)
@@ -0,0 +1,93 @@
+using System;
+using System.Data;
+using System.Data.Odbc;
+using System.Globalization;
+using System.Text;
+using System.Threading;
+
+class Program
+{
+       [STAThread]
+       static int Main ()
+       {
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return 0;
+
+               Thread.CurrentThread.CurrentCulture = 
CultureInfo.InvariantCulture;
+               Thread.CurrentThread.CurrentUICulture = 
CultureInfo.InvariantCulture;
+
+               OdbcConnection conn = new OdbcConnection 
(CreateOdbcConnectionString ());
+               conn.Open ();
+
+               OdbcCommand cmd;
+               OdbcDataReader dr;
+
+               cmd = new OdbcCommand ("SELECT @@version", conn);
+               dr = cmd.ExecuteReader ();
+               if (!dr.Read ())
+                       return 1;
+               if (dr.GetString (0).IndexOf ("Microsoft SQL Server") == -1)
+                       return 2;
+               dr.Close ();
+
+               conn.Dispose ();
+
+               return 0;
+       }
+
+       static string CreateOdbcConnectionString ()
+       {
+#if NET_2_0
+               OdbcConnectionStringBuilder csb = new 
OdbcConnectionStringBuilder ();
+               csb.Driver = "SQL Server";
+#else
+               StringBuilder sb = new StringBuilder ();
+               sb.Append ("Driver={SQL Server};");
+#endif
+
+               string serverName = Environment.GetEnvironmentVariable 
("MONO_TESTS_SQL_HOST");
+               if (serverName == null)
+                       throw CreateEnvironmentVariableNotSetException 
("MONO_TESTS_SQL_HOST");
+#if NET_2_0
+               csb.Add ("Server", serverName);
+#else
+               sb.AppendFormat ("Server={0};", serverName);
+#endif
+
+               string dbName = Environment.GetEnvironmentVariable 
("MONO_TESTS_SQL_DB");
+               if (dbName == null)
+                       throw CreateEnvironmentVariableNotSetException 
("MONO_TESTS_SQL_DB");
+#if NET_2_0
+               csb.Add ("Database", dbName);
+#else
+               sb.AppendFormat ("Database={0};", dbName);
+#endif
+
+               string userName = Environment.GetEnvironmentVariable 
("MONO_TESTS_SQL_USER");
+               if (userName != null)
+#if NET_2_0
+                       csb.Add ("Uid", userName);
+#else
+                       sb.AppendFormat ("Uid={0};", userName);
+#endif
+
+               string pwd = Environment.GetEnvironmentVariable 
("MONO_TESTS_SQL_PWD");
+               if (pwd != null)
+#if NET_2_0
+                       csb.Add ("Pwd", pwd);
+#else
+                       sb.AppendFormat ("Pwd={0};", pwd);
+#endif
+
+#if NET_2_0
+               return csb.ToString ();
+#else
+               return sb.ToString ();
+#endif
+       }
+
+       static ArgumentException CreateEnvironmentVariableNotSetException 
(string name)
+       {
+               return new ArgumentException ("The " + name + " environment 
variable is not set");
+       }
+}


Property changes on: trunk/gert/standalone/bug335329/test.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/gert/standalone/known-issues
===================================================================
--- trunk/gert/standalone/known-issues  2007-10-19 17:33:20 UTC (rev 87838)
+++ trunk/gert/standalone/known-issues  2007-10-19 18:03:47 UTC (rev 87839)
@@ -101,3 +101,4 @@
 bug334465/**
 bug334931/**
 bug335011/**
+bug335329/**

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to