Hi,
I have a situation as follows:
public abstract BaseClass
{
public static DataSet ExecuteExpensiveSqlCall(SqlParams sp){
...
}
}
public ExtendingClass : BaseClass
{
public static DataSet MethodIWantToTest(string param)
{
... //build up parameters
DataSet returnMe = ExecuteExpensiveSqlCall(sp);
...//do something with result
return returnMe;
}
}
I want to test that the MethodIWantToTest does what I want it to do with the DataSet returned by ExecuteExpensiveSqlCall, but without actually executing the expensive SQL call. Any suggestions on how to mock the ExecuteExpensiveSqlCall with TypeMock? I'd also like to have the mocked ExecuteExpensiveSqlCall return a stubbed dataset I create in my test, so that I can verify the result as such:
public void MyTest()
{
DataSet stubDataSet = new DataSet()
...//build up stub dataset
...//set up mocks
mock.ExpectAndReturn("ExecuteExpensiveSqlCall", stubDataSet, typeof(DataSet));
DataSet actual = ExtendingClass.MethodIWantToTest("ignored");
Assert.AreEqual("expected value", actual.Tables[0].Rows[0]["my_column"]);
}
Any help appreciated.
Thanks,
Nick