ConfigurationManager ConnectionString Throwing Error and returning null
<p>I am totally stunned as why one of my unit tests is failing. It is a simple test to see if the correct connectionstring is returned. My App.config looks like this: </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;configuration&gt;
   &lt;system.web&gt;
      &lt;compilation defaultLanguage="c#" debug="true" /&gt;
   &lt;/system.web&gt;
   &lt;connectionStrings&gt;
      &lt;add name="DbConnectionString" connectionString="Test_HighOnCoding_Db" /&gt;
   &lt;/connectionStrings&gt;
&lt;/configuration&gt;
</code></pre>

<p>And here is my simple unit test which always throws null exception: </p>

<pre><code>[TestFixture]
public class when_retrieving_database_name_from_config
{
    [Test]
    public void should_get_the_correct_database_name()
    {
       var dbName = ConfigurationManager.ConnectionStrings["DbConnectionString"].ConnectionString;

       // dbName is always null 

       Assert.AreEqual("Test_HighOnCoding_Db",dbName); 
    }
 }
</code></pre>
