开发者

How to run this test in NUnit

开发者 https://www.devze.com 2022-12-21 20:52 出处:网络
Why in NUnit when i write : Assert.AreEqual(ConfigurationManager.ConnectionString开发者_开发技巧s[\"FertigungRead\"].ConnectionString , \"Data Source=server511;Initial Catalog=FERTIGUNG;Persist Secur

Why in NUnit when i write : Assert.AreEqual(ConfigurationManager.ConnectionString开发者_开发技巧s["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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消