TestDriven.NET hangs for tests that connect to the database
So I'm writing a web service that connects to a remote PostgreSQL server, pulls some data and then I do stuff with the data. Currently, I'm writing unit tests to ensure that I can grab the data and my List<T>
has a count greater than zero.
I have a private PostgresSQL connection:
private NpgsqlConnection _conn;
In the test fixture setup, I open the connection:
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
_conn = DAL.ConnectToPostgeSQL();
}
Write some tests...example:
[Test]
public void CanGetSubmissions()
{
List<Submission> submission = DAL.GetSubmissions(_conn);
Assert.GreaterThan(submission.Count, 0);
}
Then, I tear down to close out the connections:
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
_conn.Close();
_conn.Dispose();
}
The trouble is that after the test(s) (can occur if I only run one test), it passes and then just hangs until I stop TestDriven.NET.
Any thoughts on this? I'm thinking that it has to do开发者_如何学Python with the PostgreSQL connection, because when I remove those, the tests will fail and everything tears down as it should.
Open and close connection for each test - Setup & TearDown instead of TestFixtureSetup & TestFixtureTeardown
精彩评论