Using: Microsoft Unit Testing Framework integrated with VS2010
I have a class that implements this interface.
public interface IConnectionManager
{
IDbConnection OpenDatabase(string path);
void CloseDatabase();
}
I would like to create a set of Tests for these methods but not quite sure how to proceed.
What is the best way to test this?
Thanks.
My OpenDatabase
implementation looks something like this:
public OleDbConnection OpenDatabase (string p_path)
{
if (Library.StringOperations.IsNullOrEmpty (p_path))
return null;
bool error = false;
string connectionString= @"CONNECTION STRING HERE";
try
{
OleDbConnection con= new OleDbConnection (connectionString);
con.Open ();
}
catch (Exception)
{
error = true;
}
if (!error)
return con;
return null;
}
As suggested by @rdkleine I want to test the returned connection.
A few questions:
Do I need to create a new OleDbConnection object to compare with my returned object or should I check my returned connection object proprieties?
Can Mock Objects be used in this case?
Having in mind that I am testing a connection to a DB is this still Unit Testing or Integration Testing ?
Thanks again.
Start simple.
etc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.