When i run a simple test on connection to DB check i receive an error in NUnit:
[Test]
public void TestConn()
{
string connectionString = ConfigurationManager.ConnectionStrings["FertigungRead"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
Assert.AreEqual(ConnectionState.Open, connection.State);
connection.Close();
}
System.NullReferenceException : Object reference not set to an instance of an object.
on line :
connectionString = ConfigurationManager.ConnectionStrings["FertigungRead"].ConnectionString;
Can i use ConfigurationManager in tests?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…