KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to write a unit test for my project, but it will not let me use the Configuration Manager. Right now my project is set up like ASP.Net application (all aspx pages) ProjectCore (all C# files - model) ProjectTest (all tests) in my ProjectCore, I am able to access the ConfigurationManager object from System.Configuration and pass information onto the project. However, when I ran a test where the ConfigurationManager is involved, I get the error System.NullReferenceException: Object reference not set to an instance of an object. Here is an example of the test using System.Configuration; [TestMethod] public void TestDatabaseExists() { //Error when I declare ConfigurationManager Assert.IsNotNull(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString } in my other tests, ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString is what I set my data adapter's configuration string to, and returns a null error on the tests but not when I actually use the website. Any ideas?
Tags (comma-separated)
Save Edits
Cancel