I was doing what all the cool kids were doing these days, test-driven development. Just the name sparks excitement and intrigue, and makes me want to travel to exotic locations sipping martinis that have been shaken, not stirred. But instead, I’ll probably sit here and look at cube walls.
In my test project, I wrote a test to verify that my connection string exists:
public void Verify_connection_string_exists()
Beautiful. But when I ran my test, I got this message: Object reference not set to an instance of an object.
I tried not to take this personally. After all, unit tests generally don’t have a dislike for an individual programmer, they hate all programmers equally. In this case, I had the minor issue of not having an App.config file in my test project, so the ConfigurationManager class had nothing to pull from.
So, I dragged and dropped the web.config file from the web project I was testing into my test project and renamed it App.config in test project.
And that was it. Once I ran the code again, my simple mistake was erased, never to be heard from again until I forget to include my config file in my project and need this post to remind me.