views:

29

answers:

1

Why in NUnit when i write : Assert.AreEqual(ConfigurationManager.ConnectionStrings["FertigungRead"].ConnectionString , "Data Source=server511;Initial Catalog=FERTIGUNG;Persist Security Info=True");

it does not run the test and raises an error : Object reference not set to an instance of an object.

But ConfigurationManager is static class. So how can i run this test?

+2  A: 

It is running the test - but the test is failing, because ConfigurationManager.ConnectionStrings["FertigungRead"] is returning null. See this post about app.config files an NUnit, as that's where it'll be getting the configuration from.

However, I don't really see a test for a config file value as a valuable unit test... is this part of a more reasonable test?

Jon Skeet
yes it is part of more reasonable test, but the error is in the part with ConfigurationManager, so i mentioned only it .
Mike
and i copied the app.config file to the project where i am runing test and have nunit.framework reference included ,but it still doesn't work
Mike