Hello,

I came across a really strange problem.  I have to say that I'm
relatively new to mbUnit so maybe I'm missing something obvious - but
I had to post this because I just don't get it.

I can sucessfully connect to ODBC database outside of MbUnit, but the
same code fails (throws Mysql connect exception) when run inside
MbUnit.  What's even more strange is that if I rerun the same test
with no code change the second time, there is no exception thrown.
And that's not where the strangeness ends.  If I comment "IList list =
Controller.ColumnList;" the test will always succeed with no MySQL
exception.  If you look at that piece of code, it does nothing related
with the database.  It just returns an empty IList.  The exception
trace even says that it's not that line of code that's throwing the
exception, it's the line above.  That makes sense - but why in the
heck does it work just fine when "IList list =" is commented out.
Sorry if this post doesn't make sense ... the whole thing doesn't make
sense.

I should add that I had something similar happen to the same code when
I used NUnit on it.  I changed to MbUnit partly because I thought
NUnit was messed up.  Actually NUnit made a bit more sense, in NUnit,
the MySQL exception was thrown every single time during
Controller.Initialize() ... none of this: it-works-on-a-second-try-if-
you-click-run-again

Here is my test code:
        [Test]
        public void Test()
        {

            Controller.Initialize();
            IList list = Controller.ColumnList;

            //I know I don't have any assert code here, but I tried to
keep the test to a minimum since it's behaving strange

        }


Controller code:

    public class Controller
    {
        private static List<string> groupTaggedColumns = new
List<string>();
        private static OdbcConnection connection;

        public static IList ColumnList
        {
            get
            {
                return groupTaggedColumns;
            }
        }

        public static void Initialize(string DSNstring)
        {
             connection = new OdbcConnection(DSNstring);
            connection.Open();
        }
}


Exception
(BTW I'm not even connecting to localhost, my DSN is setup to connect
to another host - again works fine with that line commented out):


Message: ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL
server on 'localhost' (10061)
ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on
'localhost' (10061)

Type: System.Data.Odbc.OdbcException
Source:
Errors: System.Data.Odbc.OdbcErrorCollection
ErrorCode: -2146232009
TargetSite: Void HandleError(System.Data.Odbc.OdbcHandle, RetCode)
HelpLink: null
Stack:   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle
hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection
connection, OdbcConnectionString constr, OdbcEnvironmentHandle
environmentHandle)
   at System.Data.Odbc.OdbcConnectionFactory.CreateConnection
(DbConnectionOptions options, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningObject)
   at
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection
(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection
(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection
(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()
   at StretchBase.Core.Controller.Initialize(String DSNstring) in
xxxxxxxxxxxxxx
   at StretchBase.MbUnit.ColumnListTests.Test() in xxxxxxxxxxxx


Please help - I'm out of ideas.
Thank you!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to