0

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?

Mike
  • 659
  • 2
  • 7
  • 9
  • check the my answer to one of your other questions http://stackoverflow.com/questions/2409208/the-problem-with-nunit-and-app-config/5821977#5821977 – skyfoot May 04 '11 at 17:12

1 Answers1

2

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
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • yes it is part of more reasonable test, but the error is in the part with ConfigurationManager, so i mentioned only it . – Mike Mar 05 '10 at 10:17
  • 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 Mar 05 '10 at 10:22