List:Commits« Previous MessageNext Message »
From:rburnett Date:December 3 2007 5:38pm
Subject:Connector/NET commit: r1120 - in trunk: MySql.Web/Providers MySql.Web/Providers/Properties MySql.Web/Providers/Source MySql.Web/Tests TestSuite/Source...
View as plain text  
Added:
   trunk/MySql.Web/Providers/Properties/schema1.sql
   trunk/MySql.Web/Providers/Properties/schema2.sql
   trunk/MySql.Web/Providers/Properties/schema3.sql
   trunk/MySql.Web/Providers/Source/SchemaManager.cs
Modified:
   trunk/MySql.Web/Providers/MySql.Web.csproj
   trunk/MySql.Web/Providers/Properties/Resources.resx
   trunk/MySql.Web/Tests/BaseTest.cs
   trunk/MySql.Web/Tests/SchemaTests.cs
   trunk/TestSuite/Source/BaseTest.cs
Log:
finished the upgrade and test code for the new v3 schema

Modified: trunk/MySql.Web/Providers/MySql.Web.csproj
===================================================================
--- trunk/MySql.Web/Providers/MySql.Web.csproj	2007-12-03 17:36:20 UTC (rev 1119)
+++ trunk/MySql.Web/Providers/MySql.Web.csproj	2007-12-03 17:38:15 UTC (rev 1120)
@@ -2,7 +2,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>8.0.50727</ProductVersion>
+    <ProductVersion>9.0.21022</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{C28B1166-1380-445D-AEC1-8A18B990DD18}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -59,11 +59,9 @@
       <SubType>Component</SubType>
     </Compile>
     <Compile Include="Source\ProfileProvider.cs" />
-    <Compile Include="Source\ProfileSchema.cs" />
-    <Compile Include="Source\RoleSchema.cs" />
     <Compile Include="Source\MembershipProvider.cs" />
     <Compile Include="Source\RoleProvider.cs" />
-    <Compile Include="Source\MembershipSchema.cs" />
+    <Compile Include="Source\SchemaManager.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\Driver\MySql.Data.csproj">
@@ -78,6 +76,11 @@
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="Properties\schema1.sql" />
+    <None Include="Properties\schema2.sql" />
+    <None Include="Properties\schema3.sql" />
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

Modified: trunk/MySql.Web/Providers/Properties/Resources.resx
===================================================================
--- trunk/MySql.Web/Providers/Properties/Resources.resx	2007-12-03 17:36:20 UTC (rev 1119)
+++ trunk/MySql.Web/Providers/Properties/Resources.resx	2007-12-03 17:38:15 UTC (rev 1120)
@@ -120,4 +120,14 @@
   <data name="CannotRetrieveHashedPasswords" xml:space="preserve">
     <value>Setting EnablePasswordRetrieval to true when PasswordFormat is Hashed is not supported.</value>
   </data>
+  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  <data name="schema1" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>schema1.sql;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+  </data>
+  <data name="schema2" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>schema2.sql;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+  </data>
+  <data name="schema3" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>schema3.sql;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+  </data>
 </root>
\ No newline at end of file

Added: trunk/MySql.Web/Providers/Properties/schema1.sql
===================================================================
--- trunk/MySql.Web/Providers/Properties/schema1.sql	                        (rev 0)
+++ trunk/MySql.Web/Providers/Properties/schema1.sql	2007-12-03 17:38:15 UTC (rev 1120)
@@ -0,0 +1,33 @@
+CREATE TABLE  mysql_Membership(`PKID` varchar(36) NOT NULL,
+              Username varchar(255) NOT NULL, 
+              ApplicationName varchar(255) NOT NULL,
+              Email varchar(128) NOT NULL, 
+              Comment varchar(255) default NULL,
+              Password varchar(128) NOT NULL, 
+              PasswordQuestion varchar(255) default NULL,
+              PasswordAnswer varchar(255) default NULL, 
+              IsApproved tinyint(1) default NULL,
+              LastActivityDate datetime default NULL, 
+              LastLoginDate datetime default NULL,
+              LastPasswordChangedDate datetime default NULL, 
+              CreationDate datetime default NULL,
+              IsOnline tinyint(1) default NULL, 
+              IsLockedOut tinyint(1) default NULL,
+              LastLockedOutDate datetime default NULL, 
+              FailedPasswordAttemptCount int(10) unsigned default NULL,
+              FailedPasswordAttemptWindowStart datetime default NULL,
+              FailedPasswordAnswerAttemptCount int(10) unsigned default NULL,
+              FailedPasswordAnswerAttemptWindowStart datetime default NULL,
+              PRIMARY KEY  (`PKID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='1';
+              
+CREATE TABLE  mysql_UsersInRoles(`Username` varchar(255) NOT NULL,
+                `Rolename` varchar(255) NOT NULL, `ApplicationName` varchar(255) NOT NULL,
+                KEY `Username` (`Username`,`Rolename`,`ApplicationName`)
+                ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+CREATE TABLE mysql_Roles(`Rolename` varchar(255) NOT NULL,
+                `ApplicationName` varchar(255) NOT NULL, 
+                KEY `Rolename` (`Rolename`,`ApplicationName`)
+                ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+                
+                
\ No newline at end of file

Added: trunk/MySql.Web/Providers/Properties/schema2.sql
===================================================================
--- trunk/MySql.Web/Providers/Properties/schema2.sql	                        (rev 0)
+++ trunk/MySql.Web/Providers/Properties/schema2.sql	2007-12-03 17:38:15 UTC (rev 1120)
@@ -0,0 +1,7 @@
+ ALTER TABLE mysql_Membership 
+            ADD PasswordKey char(32) AFTER Password, 
+            ADD PasswordFormat tinyint AFTER PasswordKey, 
+            CHANGE email email VARCHAR(128), COMMENT='2';
+            
+            
+                
\ No newline at end of file

Added: trunk/MySql.Web/Providers/Properties/schema3.sql
===================================================================
--- trunk/MySql.Web/Providers/Properties/schema3.sql	                        (rev 0)
+++ trunk/MySql.Web/Providers/Properties/schema3.sql	2007-12-03 17:38:15 UTC (rev 1120)
@@ -0,0 +1,77 @@
+/* Provider schema block -- version 3 */
+
+/* create our application and user tables */
+create table my_aspnet_Applications(id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(256), description VARCHAR(256));
+create table my_aspnet_Users(id INT PRIMARY KEY AUTO_INCREMENT, applicationId INT, name VARCHAR(256), isAnonymous TINYINT(1), lastActivityDate DATETIME);
+create table my_aspnet_Profiles(userId INT PRIMARY KEY, valueindex longtext, stringdata longtext, binarydata longblob, lastUpdatedDate timestamp);
+create table my_aspnet_SchemaVersion(version INT);
+ 
+insert into my_aspnet_SchemaVersion VALUES (3);
+ 
+/* now we need to migrate all applications into our apps table */
+insert into my_aspnet_Applications (name) select ApplicationName from mysql_membership UNION select ApplicationName from mysql_UsersInRoles;
+
+/* now we make our changes to the existing tables */
+alter table mysql_membership
+          rename to my_aspnet_Membership,
+          drop primary key,
+          drop column pkid,
+          add column userId INT FIRST,
+          add column applicationId INT AFTER userId;
+          
+alter table mysql_roles
+          rename to my_aspnet_Roles,
+          drop key rolename,
+          add column id INT PRIMARY KEY AUTO_INCREMENT FIRST,
+          add column applicationId INT AFTER id;
+          
+alter table mysql_UsersInRoles
+          drop key username,
+          rename to my_aspnet_UsersInRoles,
+          add column userId INT FIRST,
+          add column roleId INT AFTER userId,
+          add column applicationId INT AFTER roleId;
+
+/* these next lines set the application Id on our tables appropriately */          
+update my_aspnet_Membership m, my_aspnet_Applications a set m.applicationId = a.id where a.name=m.ApplicationName;
+update my_aspnet_Roles r, my_aspnet_Applications a set r.applicationId = a.id where a.name=r.ApplicationName;
+update my_aspnet_UsersInRoles u, my_aspnet_Applications a set u.applicationId = a.id where a.name=u.ApplicationName;
+
+/* now merge our usernames into our users table */
+insert into my_aspnet_Users (applicationId, name) 
+        select applicationId, username from my_aspnet_membership
+        UNION select applicationId, username from my_aspnet_UsersInRoles; 
+          
+/* now set the user ids in our tables accordingly */        
+update my_aspnet_Membership m, my_aspnet_Users u set m.userId = u.id where u.name=m.UserName AND u.applicationId=m.ApplicationId;
+update my_aspnet_UsersInRoles r, my_aspnet_Users u set r.userId = u.id where u.name=r.UserName AND u.applicationId=r.applicationId;
+
+/* now update the isanonymous and last activity date fields for the users */        
+update my_aspnet_users u, my_aspnet_membership m 
+        set u.isAnonymous=0, u.lastActivityDate=m.lastActivityDate 
+        where u.name = m.username;
+
+/* make final changes to our tables */        
+alter table my_aspnet_Membership
+          drop column username,
+          drop column applicationName,
+          drop column applicationId,
+          add primary key (userId);
+          
+/* next we set our role id values appropriately */
+update my_aspnet_UsersInRoles u, my_aspnet_Roles r set u.roleId = r.id where u.rolename = r.rolename and r.applicationId=u.applicationId;
+
+/* now we make the final changes to our roles tables */                    
+alter table my_aspnet_Roles
+          drop column applicationName,
+          change column rolename name VARCHAR(255) NOT NULL;
+          
+alter table my_aspnet_UsersInRoles
+          drop column applicationName,
+          drop column applicationId,
+          drop column username,
+          drop column rolename,
+          add primary key (userId, roleId);
+          
+          
+          
\ No newline at end of file

Added: trunk/MySql.Web/Providers/Source/SchemaManager.cs
===================================================================
--- trunk/MySql.Web/Providers/Source/SchemaManager.cs	                        (rev 0)
+++ trunk/MySql.Web/Providers/Source/SchemaManager.cs	2007-12-03 17:38:15 UTC (rev 1120)
@@ -0,0 +1,88 @@
+// Copyright (C) 2007 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL 
+// as it is applied to this software. View the full text of the 
+// exception in file EXCEPTIONS in the directory of this software 
+// distribution.
+//
+// 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, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+
+//  This code was contributed by Sean Wright (srwright@stripped) on 2007-01-12
+//  The copyright was assigned and transferred under the terms of
+//  the MySQL Contributor License Agreement (CLA)
+
+using System;
+using System.Data;
+using MySql.Data.MySqlClient;
+using System.Collections.Specialized;
+using System.Configuration.Provider;
+using System.Resources;
+using System.IO;
+
+namespace MySql.Web.Security
+{
+    public static class SchemaManager
+    {
+        private const int schemaVersion = 3;
+
+        /// <summary>
+        /// Gets the most recent version of the schema.
+        /// </summary>
+        /// <value>The most recent version number of the schema.</value>
+        public static int Version
+        {
+            get { return schemaVersion; }
+        }
+
+        internal static void CheckSchema(string connectionString, NameValueCollection config)
+        {
+            // make sure the user doesn't use autogenerateschema any longer
+            foreach (string key in config.AllKeys)
+                if (key.ToLowerInvariant() == "autogenerateschema")
+                    throw new ProviderException(
+                        "AutoGenerateSchema is not a valid configuration option.");
+
+            try
+            {
+                int ver = GetSchemaVersion(connectionString);
+                if (ver == Version) return;
+            }
+            catch (Exception) { }
+
+            throw new ProviderException(
+                "Unable to initialize provider.  Possibly missing or incorrect schema version.");
+        }
+
+        private static int GetSchemaVersion(string connectionString)
+        {
+            // retrieve the current schema version
+            using (MySqlConnection conn = new MySqlConnection(connectionString))
+            {
+                conn.Open();
+
+                string[] restrictions = new string[4];
+                restrictions[2] = "mysql_Membership";
+                DataTable dt = conn.GetSchema("Tables", restrictions);
+                if (dt.Rows.Count == 1)
+                    return Convert.ToInt32(dt.Rows[0]["TABLE_COMMENT"]);
+
+                MySqlCommand cmd = new MySqlCommand("SELECT * FROM my_aspnet_SchemaVersion", conn);
+                object ver = cmd.ExecuteScalar();
+                if (ver == null)
+                    return 0;
+                return (int)ver;
+            }
+        }
+    }
+}
\ No newline at end of file

Modified: trunk/MySql.Web/Tests/BaseTest.cs
===================================================================
--- trunk/MySql.Web/Tests/BaseTest.cs	2007-12-03 17:36:20 UTC (rev 1119)
+++ trunk/MySql.Web/Tests/BaseTest.cs	2007-12-03 17:38:15 UTC (rev 1120)
@@ -74,12 +74,10 @@
 			ConfigurationManager.RefreshSection("system.web/membership");
 		}
 
-        protected DataTable GetMembers()
+        [TestFixtureSetUp]
+        public override void FixtureSetup()
         {
-            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM mysql_membership", conn);
-            DataTable dt = new DataTable();
-            da.Fill(dt);
-            return dt;
+            base.FixtureSetup();
         }
     }
 }

Modified: trunk/MySql.Web/Tests/SchemaTests.cs
===================================================================
--- trunk/MySql.Web/Tests/SchemaTests.cs	2007-12-03 17:36:20 UTC (rev 1119)
+++ trunk/MySql.Web/Tests/SchemaTests.cs	2007-12-03 17:38:15 UTC (rev 1120)
@@ -26,6 +26,11 @@
 using MySql.Web.Security;
 using System.Collections.Specialized;
 using MySql.Data.MySqlClient;
+using System.Resources;
+using System.Data;
+using System;
+using System.IO;
+using System.Configuration.Provider;
 
 namespace MySql.Web.Security.Tests
 {
@@ -33,83 +38,256 @@
     public class SchemaTests : BaseWebTest
     {
         [SetUp]
-        protected override void Setup()
+        public override void Setup()
         {
 			base.Setup();
 
-            execSQL("DROP TABLE IF EXISTS mysql_Membership");
-            execSQL("DROP TABLE IF EXISTS mysql_Roles");
-            execSQL("DROP TABLE IF EXISTS mysql_UsersInRoles");
+            DataTable dt = conn.GetSchema("Tables");
+            foreach (DataRow row in dt.Rows)
+                execSQL(String.Format("DROP TABLE IF EXISTS {0}", row["TABLE_NAME"]));
         }
 
         [Test]
-        public void CurrentSchema()
+        public void SchemaNotPresent()
         {
             MySQLMembershipProvider provider = new MySQLMembershipProvider();
             NameValueCollection config = new NameValueCollection();
             config.Add("connectionStringName", "LocalMySqlServer");
-            provider.Initialize(null, config);
+            config.Add("applicationName", "/");
+            config.Add("passwordFormat", "Clear");
 
-            MySqlCommand cmd = new MySqlCommand("SHOW CREATE TABLE mysql_membership", conn);
-            using (MySqlDataReader reader = cmd.ExecuteReader())
+            try
             {
-                reader.Read();
-                string createTable = reader.GetString(1);
-                int index = createTable.IndexOf("COMMENT='2'");
-                Assert.AreNotEqual(-1, index);
+                provider.Initialize(null, config);
+                Assert.Fail("Should have failed");
             }
+            catch (ProviderException)
+            {
+            }
         }
 
         [Test]
-        public void UpgradeV1ToV2()
+        public void SchemaV1Present()
         {
-            execSQL(schema1);
+            MySQLMembershipProvider provider = new MySQLMembershipProvider();
+            NameValueCollection config = new NameValueCollection();
+            config.Add("connectionStringName", "LocalMySqlServer");
+            config.Add("applicationName", "/");
+            config.Add("passwordFormat", "Clear");
 
+            LoadSchema(1);
+            try
+            {
+                provider.Initialize(null, config);
+                Assert.Fail("Should have failed");
+            }
+            catch (ProviderException)
+            {
+            }
+        }
+
+        [Test]
+        public void SchemaV2Present()
+        {
             MySQLMembershipProvider provider = new MySQLMembershipProvider();
             NameValueCollection config = new NameValueCollection();
             config.Add("connectionStringName", "LocalMySqlServer");
-            provider.Initialize(null, config);
+            config.Add("applicationName", "/");
+            config.Add("passwordFormat", "Clear");
 
+            LoadSchema(1);
+            LoadSchema(2);
+            try
+            {
+                provider.Initialize(null, config);
+                Assert.Fail("Should have failed");
+            }
+            catch (ProviderException)
+            {
+            }
+        }
+
+        [Test]
+        public void SchemaV3Present()
+        {
+            MySQLMembershipProvider provider = new MySQLMembershipProvider();
+            NameValueCollection config = new NameValueCollection();
+            config.Add("connectionStringName", "LocalMySqlServer");
+            config.Add("applicationName", "/");
+            config.Add("passwordFormat", "Clear");
+
+            LoadSchema(1);
+            LoadSchema(2);
+            LoadSchema(3);
+            try
+            {
+                provider.Initialize(null, config);
+            }
+            catch (ProviderException)
+            {
+                Assert.Fail("Should not have failed");
+            }
+        }
+
+        private void LoadSchema(int version)
+        {
+            if (version < 1) return;
+
+            MySQLMembershipProvider provider = new MySQLMembershipProvider();
+
+            ResourceManager r = new ResourceManager("MySql.Web.Properties.Resources", typeof(MySQLMembershipProvider).Assembly);
+            string schema = r.GetString(String.Format("schema{0}", version));
+            MySqlScript script = new MySqlScript(conn);
+            script.Query = schema;
+            script.Execute();
+        }
+
+        [Test]
+        public void CurrentSchema()
+        {
+            LoadSchema(1);
+            LoadSchema(2);
+            LoadSchema(3);
+
+            MySqlCommand cmd = new MySqlCommand("SELECT * FROM my_aspnet_SchemaVersion", conn);
+            object ver = cmd.ExecuteScalar();
+            Assert.AreEqual(3, ver);
+        }
+
+        [Test]
+        public void UpgradeV1ToV2()
+        {
+            LoadSchema(1);
+
             MySqlCommand cmd = new MySqlCommand("SHOW CREATE TABLE mysql_membership", conn);
             using (MySqlDataReader reader = cmd.ExecuteReader())
             {
                 reader.Read();
                 string createTable = reader.GetString(1);
+                int index = createTable.IndexOf("COMMENT='1'");
+                Assert.AreNotEqual(-1, index);
+            }
+
+            LoadSchema(2);
+            cmd = new MySqlCommand("SHOW CREATE TABLE mysql_membership", conn);
+            using (MySqlDataReader reader = cmd.ExecuteReader())
+            {
+                reader.Read();
+                string createTable = reader.GetString(1);
                 int index = createTable.IndexOf("COMMENT='2'");
                 Assert.AreNotEqual(-1, index);
             }
         }
 
-        #region Schema
+        private void LoadData()
+        {
+            LoadSchema(1);
+            LoadSchema(2);
+            execSQL(@"INSERT INTO mysql_membership (pkid, username, applicationname, lastactivitydate) 
+                VALUES('1', 'user1', 'app1', '2007-01-01')");
+            execSQL(@"INSERT INTO mysql_membership (pkid, username, applicationname, lastactivitydate) 
+                VALUES('2', 'user2', 'app1', '2007-01-01')");
+            execSQL(@"INSERT INTO mysql_membership (pkid, username, applicationname, lastactivitydate) 
+                VALUES('3', 'user1', 'app2', '2007-01-01')");
+            execSQL(@"INSERT INTO mysql_membership (pkid, username, applicationname, lastactivitydate) 
+                VALUES('4', 'user2', 'app2', '2007-01-01')");
+            execSQL(@"INSERT INTO mysql_roles VALUES ('role1', 'app1')");
+            execSQL(@"INSERT INTO mysql_roles VALUES ('role2', 'app1')");
+            execSQL(@"INSERT INTO mysql_roles VALUES ('role1', 'app2')");
+            execSQL(@"INSERT INTO mysql_roles VALUES ('role2', 'app2')");
+            execSQL(@"INSERT INTO mysql_UsersInRoles VALUES ('user1', 'role1', 'app1')");
+            execSQL(@"INSERT INTO mysql_UsersInRoles VALUES ('user2', 'role2', 'app1')");
+            execSQL(@"INSERT INTO mysql_UsersInRoles VALUES ('user1', 'role1', 'app2')");
+            execSQL(@"INSERT INTO mysql_UsersInRoles VALUES ('user2', 'role2', 'app2')");
+            LoadSchema(3);
+            Assert.IsFalse(TableExists("mysql_membership"));
+            Assert.IsFalse(TableExists("mysql_roles"));
+            Assert.IsFalse(TableExists("mysql_usersinroles"));
+        }
 
-        private const string schema1 =
-                @"CREATE TABLE  mysql_Membership(`PKID` varchar(36) NOT NULL,
-                `Username` varchar(255) NOT NULL, 
-                `ApplicationName` varchar(255) NOT NULL,
-                `Email` varchar(128) NOT NULL, 
-                `Comment` varchar(255) default NULL,
-                `Password` varchar(128) NOT NULL, 
-                `PasswordQuestion` varchar(255) default NULL,
-                `PasswordAnswer` varchar(255) default NULL, 
-                `IsApproved` tinyint(1) default NULL,
-                `LastActivityDate` datetime default NULL, 
-                `LastLoginDate` datetime default NULL,
-                `LastPasswordChangedDate` datetime default NULL, 
-                `CreationDate` datetime default NULL,
-                `IsOnline` tinyint(1) default NULL, 
-                `IsLockedOut` tinyint(1) default NULL,
-                `LastLockedOutDate` datetime default NULL, 
-                `FailedPasswordAttemptCount` int(10) unsigned default NULL,
-                `FailedPasswordAttemptWindowStart` datetime default NULL,
-                `FailedPasswordAnswerAttemptCount` int(10) unsigned default NULL,
-                `FailedPasswordAnswerAttemptWindowStart` datetime default NULL,
-                PRIMARY KEY  (`PKID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='1'";
+        [Test]
+        public void CheckAppsUpgrade()
+        {
+            LoadData();
 
-        private const string schema2 =
-            @"ALTER TABLE mysql_Membership 
-            ADD COLUMN PasswordKey char(16) AFTER Password, 
-            ADD COLUMN PasswordFormat tinyint AFTER PasswordKey, COMMENT='2'";
+            DataTable apps = FillTable("SELECT * FROM my_aspnet_Applications");
+            Assert.AreEqual(2, apps.Rows.Count);
+            Assert.AreEqual(1, apps.Rows[0]["id"]);
+            Assert.AreEqual("app1", apps.Rows[0]["name"]);
+            Assert.AreEqual(2, apps.Rows[1]["id"]);
+            Assert.AreEqual("app2", apps.Rows[1]["name"]);
+        }
 
-        #endregion
+        [Test]
+        public void CheckUsersUpgrade()
+        {
+            LoadData();
+
+            DataTable dt = FillTable("SELECT * FROM my_aspnet_Users");
+            Assert.AreEqual(4, dt.Rows.Count);
+            Assert.AreEqual(1, dt.Rows[0]["id"]);
+            Assert.AreEqual(1, dt.Rows[0]["applicationId"]);
+            Assert.AreEqual("user1", dt.Rows[0]["name"]);
+            Assert.AreEqual(2, dt.Rows[1]["id"]);
+            Assert.AreEqual(1, dt.Rows[1]["applicationId"]);
+            Assert.AreEqual("user2", dt.Rows[1]["name"]);
+            Assert.AreEqual(3, dt.Rows[2]["id"]);
+            Assert.AreEqual(2, dt.Rows[2]["applicationId"]);
+            Assert.AreEqual("user1", dt.Rows[2]["name"]);
+            Assert.AreEqual(4, dt.Rows[3]["id"]);
+            Assert.AreEqual(2, dt.Rows[3]["applicationId"]);
+            Assert.AreEqual("user2", dt.Rows[3]["name"]);
+        }
+           
+        [Test]
+        public void CheckRolesUpgrade()
+        {
+            LoadData();
+
+            DataTable dt = FillTable("SELECT * FROM my_aspnet_Roles");
+            Assert.AreEqual(4, dt.Rows.Count);
+            Assert.AreEqual(1, dt.Rows[0]["id"]);
+            Assert.AreEqual(1, dt.Rows[0]["applicationId"]);
+            Assert.AreEqual("role1", dt.Rows[0]["name"]);
+            Assert.AreEqual(2, dt.Rows[1]["id"]);
+            Assert.AreEqual(1, dt.Rows[1]["applicationId"]);
+            Assert.AreEqual("role2", dt.Rows[1]["name"]);
+            Assert.AreEqual(3, dt.Rows[2]["id"]);
+            Assert.AreEqual(2, dt.Rows[2]["applicationId"]);
+            Assert.AreEqual("role1", dt.Rows[2]["name"]);
+            Assert.AreEqual(4, dt.Rows[3]["id"]);
+            Assert.AreEqual(2, dt.Rows[3]["applicationId"]);
+            Assert.AreEqual("role2", dt.Rows[3]["name"]);
+        }
+
+        [Test]
+        public void CheckMembershipUpgrade()
+        {
+            LoadData();
+
+            DataTable dt = FillTable("SELECT * FROM my_aspnet_Membership");
+            Assert.AreEqual(4, dt.Rows.Count);
+            Assert.AreEqual(1, dt.Rows[0]["userid"]);
+            Assert.AreEqual(2, dt.Rows[1]["userid"]);
+            Assert.AreEqual(3, dt.Rows[2]["userid"]);
+            Assert.AreEqual(4, dt.Rows[3]["userid"]);
+        }
+
+        [Test]
+        public void CheckUsersInRolesUpgrade()
+        {
+            LoadData();
+
+            DataTable dt = FillTable("SELECT * FROM my_aspnet_UsersInRoles");
+            Assert.AreEqual(4, dt.Rows.Count);
+            Assert.AreEqual(1, dt.Rows[0]["userid"]);
+            Assert.AreEqual(1, dt.Rows[0]["roleid"]);
+            Assert.AreEqual(2, dt.Rows[1]["userid"]);
+            Assert.AreEqual(2, dt.Rows[1]["roleid"]);
+            Assert.AreEqual(3, dt.Rows[2]["userid"]);
+            Assert.AreEqual(3, dt.Rows[2]["roleid"]);
+            Assert.AreEqual(4, dt.Rows[3]["userid"]);
+            Assert.AreEqual(4, dt.Rows[3]["roleid"]);
+        }
     }
 }

Modified: trunk/TestSuite/Source/BaseTest.cs
===================================================================
--- trunk/TestSuite/Source/BaseTest.cs	2007-12-03 17:36:20 UTC (rev 1119)
+++ trunk/TestSuite/Source/BaseTest.cs	2007-12-03 17:38:15 UTC (rev 1120)
@@ -314,5 +314,21 @@
             da.Fill(dt);
             return dt.Rows.Count;
         }
+
+        protected bool TableExists(string tableName)
+        {
+            string[] restrictions = new string[4];
+            restrictions[2] = tableName;
+            DataTable dt = conn.GetSchema("Tables", restrictions);
+            return dt.Rows.Count > 0;
+        }
+
+        protected DataTable FillTable(string sql)
+        {
+            MySqlDataAdapter da = new MySqlDataAdapter(sql, conn);
+            DataTable dt = new DataTable();
+            da.Fill(dt);
+            return dt;
+        }
     }
 }

Thread
Connector/NET commit: r1120 - in trunk: MySql.Web/Providers MySql.Web/Providers/Properties MySql.Web/Providers/Source MySql.Web/Tests TestSuite/Sourcerburnett3 Dec