Author: gert
Date: 2007-10-18 10:58:44 -0400 (Thu, 18 Oct 2007)
New Revision: 87755

Added:
   trunk/gert/build/
   trunk/gert/build/common/
   trunk/gert/build/common/Assert.cs
Removed:
   trunk/gert/standalone/bug333082/Assert.cs
   trunk/gert/standalone/bug334842/Assert.cs
Modified:
   trunk/gert/standalone/bug318854/test.cs
   trunk/gert/standalone/bug325397/test.cs
   trunk/gert/standalone/bug326011/test.cs
   trunk/gert/standalone/bug333082/default.build
   trunk/gert/standalone/bug333082/test.cs
   trunk/gert/standalone/bug333901/test.cs
   trunk/gert/standalone/bug334842/default.build
   trunk/gert/standalone/bug334842/test.cs
   trunk/gert/standalone/bug66630/test.cs
   trunk/gert/standalone/local-tests
Log:
Added common Assert class.
Removed a few bug-specific Assert classes.
Only run SQL Server tests when MONO_TESTS_SQL environment variable is set.
Removed SQL Server tests from local-tests category.


Added: trunk/gert/build/common/Assert.cs
===================================================================
--- trunk/gert/build/common/Assert.cs   2007-10-18 14:32:43 UTC (rev 87754)
+++ trunk/gert/build/common/Assert.cs   2007-10-18 14:58:44 UTC (rev 87755)
@@ -0,0 +1,32 @@
+using System;
+using System.Globalization;
+
+class Assert
+{
+       public static void AreEqual (object x, object y, string msg)
+       {
+               if (x == null && y == null)
+                       return;
+               if ((x == null || y == null) || !x.Equals (y))
+                       throw new Exception (string.Format 
(CultureInfo.InvariantCulture,
+                               "Expected: {0}, but was: {1}. {2}",
+                               x, y, msg));
+       }
+
+       public static void Fail (string msg)
+       {
+               throw new Exception (msg);
+       }
+
+       public static void IsNotNull (object value, string msg)
+       {
+               if (value == null)
+                       throw new Exception (msg);
+       }
+
+       public static void IsNull (object value, string msg)
+       {
+               if (value != null)
+                       throw new Exception (msg);
+       }
+}


Property changes on: trunk/gert/build/common/Assert.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/gert/standalone/bug318854/test.cs
===================================================================
--- trunk/gert/standalone/bug318854/test.cs     2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug318854/test.cs     2007-10-18 14:58:44 UTC (rev 
87755)
@@ -8,6 +8,9 @@
        [STAThread]
        static int Main ()
        {
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return 0;
+
                OdbcConnection conn;
                OdbcCommand cmd;
 

Modified: trunk/gert/standalone/bug325397/test.cs
===================================================================
--- trunk/gert/standalone/bug325397/test.cs     2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug325397/test.cs     2007-10-18 14:58:44 UTC (rev 
87755)
@@ -8,6 +8,9 @@
        [STAThread]
        static int Main ()
        {
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return 0;
+
                SqlConnection conn = new SqlConnection (CreateConnectionString 
());
                conn.Open ();
 

Modified: trunk/gert/standalone/bug326011/test.cs
===================================================================
--- trunk/gert/standalone/bug326011/test.cs     2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug326011/test.cs     2007-10-18 14:58:44 UTC (rev 
87755)
@@ -8,7 +8,10 @@
        [STAThread]
        static void Main ()
        {
-               SqlConnection conn;
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return;
+
+               SqlConnection conn = null;
                SqlCommand cmd;
 
                try {
@@ -24,12 +27,17 @@
                        cmd = new SqlCommand (insert_data, conn);
                        cmd.ExecuteNonQuery ();
 
-                       cmd = new SqlCommand ("SELECT Name, FirstName FROM 
[Whatever]", conn);
+                       cmd = new SqlCommand ("SELECT Name, FirstName FROM 
[bug326011]", conn);
 
                        SqlDataAdapter adapter = new SqlDataAdapter (cmd);
                        DataSet ds = new DataSet ();
                        adapter.Fill (ds);
                } finally {
+                       cmd = new SqlCommand (drop_table, conn);
+                       cmd.ExecuteNonQuery ();
+
+                       if (conn != null)
+                               conn.Dispose ();
                }
 
                try {
@@ -45,7 +53,7 @@
                        cmd = new SqlCommand (insert_data, conn);
                        cmd.ExecuteNonQuery ();
 
-                       cmd = new SqlCommand ("SELECT Name, FirstName FROM 
[Whatever]", conn);
+                       cmd = new SqlCommand ("SELECT Name, FirstName FROM 
[bug326011]", conn);
 
                        SqlDataAdapter adapter = new SqlDataAdapter (cmd);
                        DataSet ds = new DataSet ();
@@ -54,6 +62,11 @@
                        cmd = new SqlCommand (drop_table, conn);
                        cmd.ExecuteNonQuery ();
                } finally {
+                       cmd = new SqlCommand (drop_table, conn);
+                       cmd.ExecuteNonQuery ();
+
+                       if (conn != null)
+                               conn.Dispose ();
                }
        }
 
@@ -87,17 +100,17 @@
        }
 
        const string drop_table = @"
-               IF EXISTS (SELECT * FROM sys.objects WHERE object_id = 
OBJECT_ID(N'[dbo].[whatever]') AND type = N'U')
-                       DROP TABLE [dbo].[whatever]";
+               IF EXISTS (SELECT * FROM sys.objects WHERE object_id = 
OBJECT_ID(N'[dbo].[bug326011]') AND type = N'U')
+                       DROP TABLE [dbo].[bug326011]";
 
        const string create_table = @"
-               CREATE TABLE whatever
+               CREATE TABLE bug326011
                (
                        Name varchar(20),
                        FirstName varchar (10)
                )";
 
        const string insert_data = @"
-               INSERT INTO whatever VALUES (N'de Icaza', N'Miguel');
-               INSERT INTO whatever VALUES (N'Pobst', N'Jonathan');";
+               INSERT INTO bug326011 VALUES (N'de Icaza', N'Miguel');
+               INSERT INTO bug326011 VALUES (N'Pobst', N'Jonathan');";
 }

Deleted: trunk/gert/standalone/bug333082/Assert.cs
===================================================================
--- trunk/gert/standalone/bug333082/Assert.cs   2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug333082/Assert.cs   2007-10-18 14:58:44 UTC (rev 
87755)
@@ -1,47 +0,0 @@
-using System;
-using System.Data;
-using System.Globalization;
-
-class Assert
-{
-       public static void AreEqual (string x, string y, string msg)
-       {
-               if (x != y)
-                       throw new Exception (string.Format 
(CultureInfo.InvariantCulture,
-                               "Expected: {0}, but was: {1}. {2}",
-                               x, y, msg));
-       }
-
-       public static void AreEqual (IsolationLevel x, IsolationLevel y, string 
msg)
-       {
-               if (x != y)
-                       throw new Exception (string.Format 
(CultureInfo.InvariantCulture,
-                               "Expected: {0}, but was: {1}. {2}",
-                               x, y, msg));
-       }
-
-       public static void AreEqual (object x, object y, string msg)
-       {
-               if (x != y)
-                       throw new Exception (string.Format 
(CultureInfo.InvariantCulture,
-                               "Expected: {0}, but was: {1}. {2}",
-                               x, y, msg));
-       }
-
-       public static void Fail (string msg)
-       {
-               throw new Exception (msg);
-       }
-
-       public static void IsNotNull (object value, string msg)
-       {
-               if (value == null)
-                       throw new Exception (msg);
-       }
-
-       public static void IsNull (object value, string msg)
-       {
-               if (value != null)
-                       throw new Exception (msg);
-       }
-}

Modified: trunk/gert/standalone/bug333082/default.build
===================================================================
--- trunk/gert/standalone/bug333082/default.build       2007-10-18 14:32:43 UTC 
(rev 87754)
+++ trunk/gert/standalone/bug333082/default.build       2007-10-18 14:58:44 UTC 
(rev 87755)
@@ -44,7 +44,7 @@
        <target name="compile">
                <csc target="exe" define="${csc.defines}" output="test.exe" 
warnaserror="true" warninglevel="4">
                        <sources>
-                               <include name="Assert.cs" />
+                               <include name="../../build/common/Assert.cs" />
                                <include name="test.cs" />
                        </sources>
                        <references>

Modified: trunk/gert/standalone/bug333082/test.cs
===================================================================
--- trunk/gert/standalone/bug333082/test.cs     2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug333082/test.cs     2007-10-18 14:58:44 UTC (rev 
87755)
@@ -9,6 +9,9 @@
        [STAThread]
        static int Main ()
        {
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return 0;
+
                SqlConnection conn = new SqlConnection (CreateConnectionString 
());
                conn.Open ();
 

Modified: trunk/gert/standalone/bug333901/test.cs
===================================================================
--- trunk/gert/standalone/bug333901/test.cs     2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug333901/test.cs     2007-10-18 14:58:44 UTC (rev 
87755)
@@ -8,6 +8,9 @@
        [STAThread]
        static int Main ()
        {
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return 0;
+
                SqlConnection conn = new SqlConnection (CreateConnectionString 
());
                SqlCommand cmd = new SqlCommand ("SLECT WHATEVER", conn);
                conn.Open ();

Deleted: trunk/gert/standalone/bug334842/Assert.cs
===================================================================
--- trunk/gert/standalone/bug334842/Assert.cs   2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug334842/Assert.cs   2007-10-18 14:58:44 UTC (rev 
87755)
@@ -1,33 +0,0 @@
-using System;
-using System.Data;
-using System.Globalization;
-
-class Assert
-{
-       public static void AreEqual (object x, object y, string msg)
-       {
-               if (x == null && y == null)
-                       return;
-               if ((x == null || y == null) || !x.Equals (y))
-                       throw new Exception (string.Format 
(CultureInfo.InvariantCulture,
-                               "Expected: {0}, but was: {1}. {2}",
-                               x, y, msg));
-       }
-
-       public static void Fail (string msg)
-       {
-               throw new Exception (msg);
-       }
-
-       public static void IsNotNull (object value, string msg)
-       {
-               if (value == null)
-                       throw new Exception (msg);
-       }
-
-       public static void IsNull (object value, string msg)
-       {
-               if (value != null)
-                       throw new Exception (msg);
-       }
-}

Modified: trunk/gert/standalone/bug334842/default.build
===================================================================
--- trunk/gert/standalone/bug334842/default.build       2007-10-18 14:32:43 UTC 
(rev 87754)
+++ trunk/gert/standalone/bug334842/default.build       2007-10-18 14:58:44 UTC 
(rev 87755)
@@ -36,7 +36,7 @@
        <target name="compile">
                <csc target="exe" define="${csc.defines}" output="test.exe" 
warnaserror="true" warninglevel="4">
                        <sources>
-                               <include name="Assert.cs" />
+                               <include name="../../build/common/Assert.cs" />
                                <include name="test.cs" />
                        </sources>
                        <references>

Modified: trunk/gert/standalone/bug334842/test.cs
===================================================================
--- trunk/gert/standalone/bug334842/test.cs     2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug334842/test.cs     2007-10-18 14:58:44 UTC (rev 
87755)
@@ -11,6 +11,9 @@
        [STAThread]
        static int Main ()
        {
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return 0;
+
                Thread.CurrentThread.CurrentCulture = 
CultureInfo.InvariantCulture;
                Thread.CurrentThread.CurrentUICulture = 
CultureInfo.InvariantCulture;
 

Modified: trunk/gert/standalone/bug66630/test.cs
===================================================================
--- trunk/gert/standalone/bug66630/test.cs      2007-10-18 14:32:43 UTC (rev 
87754)
+++ trunk/gert/standalone/bug66630/test.cs      2007-10-18 14:58:44 UTC (rev 
87755)
@@ -8,6 +8,9 @@
        [STAThread]
        static int Main ()
        {
+               if (Environment.GetEnvironmentVariable ("MONO_TESTS_SQL") == 
null)
+                       return 0;
+
                using (SqlConnection myConnection = new SqlConnection 
(CreateConnectionString ())) {
                        SqlCommand command = new SqlCommand 
(drop_stored_procedure, myConnection);
                        myConnection.Open ();
@@ -16,7 +19,7 @@
                        command = new SqlCommand (create_stored_procedure, 
myConnection);
                        command.ExecuteNonQuery ();
 
-                       command = new SqlCommand ("whatever", myConnection);
+                       command = new SqlCommand ("bug66630", myConnection);
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add ("@UserAccountStatus", 
SqlDbType.SmallInt).Value = UserAccountStatus.ApprovalPending;
                        command.Prepare ();
@@ -38,11 +41,11 @@
        }
 
        const string drop_stored_procedure = @"
-               IF EXISTS (SELECT * FROM sys.objects WHERE object_id = 
OBJECT_ID(N'[dbo].[whatever]') AND type in (N'P', N'PC'))
-                       DROP PROCEDURE [dbo].[whatever]";
+               IF EXISTS (SELECT * FROM sys.objects WHERE object_id = 
OBJECT_ID(N'[dbo].[bug66630]') AND type in (N'P', N'PC'))
+                       DROP PROCEDURE [dbo].[bug66630]";
 
        const string create_stored_procedure = @"
-                       CREATE PROCEDURE whatever
+                       CREATE PROCEDURE bug66630
                        (
                                @UserAccountStatus smallint = 1
                        )

Modified: trunk/gert/standalone/local-tests
===================================================================
--- trunk/gert/standalone/local-tests   2007-10-18 14:32:43 UTC (rev 87754)
+++ trunk/gert/standalone/local-tests   2007-10-18 14:58:44 UTC (rev 87755)
@@ -1,7 +0,0 @@
-bug66630/**
-bug318854/**
-bug325397/**
-bug326011/**
-bug333082/**
-bug333901/**
-bug334842/**

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

Reply via email to