I am trying to run a NUnit test for a method that gets a connection string from a web.config file. When I test it, it clearly crashes when trying to pull this connection string. So I poked and came to this URL:
Test module for app.config using NUnit
Here is the user code:
void BasicSetup()
{
ConnectionStringSettings connectionStringSettings = new ConnectionStringSettings();
connectionStringSettings.Name = "testmasterconnection";
connectionStringSettings.ConnectionString = "server=localhost;user=some;database=some;port=3306;";
ConfigurationManager.ConnectionStrings.Clear();
ConfigurationManager.ConnectionStrings.Add(connectionStringSettings);
}
It almost seemed like the answer I was looking for. When I actually paste the code, I get the following error: Failure: System.Configuration.ConfigurationErrorsException: read-only configuration.
Is there anything else I should do first? Thank!