コード例 #1
0
        protected void CheckConnectionStringAsUri(string connectionstring, string user, string password, string server, uint port, params string[] parameters)
        {
            string result = this.session.ParseConnectionString(connectionstring);

            MySql.Data.MySqlClient.MySqlConnectionStringBuilder csbuilder = new MySql.Data.MySqlClient.MySqlConnectionStringBuilder(result);
            Assert.True(user == csbuilder.UserID, string.Format("Expected:{0} Current:{1} in {2}", user, csbuilder.UserID, connectionstring));
            Assert.True(password == csbuilder.Password, string.Format("Expected:{0} Current:{1} in {2}", password, csbuilder.Password, connectionstring));
            Assert.True(server == csbuilder.Server, string.Format("Expected:{0} Current:{1} in {2}", server, csbuilder.Server, connectionstring));
            Assert.True(port == csbuilder.Port, string.Format("Expected:{0} Current:{1} in {2}", port, csbuilder.Port, connectionstring));
            if (parameters != null)
            {
                if (parameters.Length % 2 != 0)
                {
                    throw new ArgumentOutOfRangeException();
                }
                for (int i = 0; i < parameters.Length; i += 2)
                {
                    Assert.True(csbuilder.ContainsKey(parameters[i]));
                    Assert.Equal(parameters[i + 1], csbuilder[parameters[i]].ToString());
                }
            }
        }