I am writting Unit Test for my database connection.
I have following class
Public class A
{
public IDbConnection _dbConnection;
public A()
{
_dbConnection = new SqlConnection(connectionStringName);
}
public int ExecuteNoneQuery(CommandDefination command)
{
return _dbConnection.Execute(command);
}
}
I want to test this class, how I can test with Microsoft Stub/Shim
I have written following code, but it is not working.
[TestMethod]
public void TestMethod1()
{
StubIDbConnection stubIDbConnection = new StubIDbConnection();
stubIDbConnection.Execute =(null) => -1;
var a = new classA();
int answer = a.ExecuteNoneQuery(null);
Assert.AreEqual(-1,-1);
}
Aucun commentaire:
Enregistrer un commentaire