Given this class:
public class MyClass
{
private void MyMethod()
{
//...
}
public void Execute()
{
try
{
//...
MyMethod();
//...
}
catch(Exception e)
{
...
}
}
}
How can I Mock MyMethod to throw an OutOfmemoryException
?
EDIT 1:
Given the next situation where MyMethod
loads some data from database, and some unpredicted error occurs, MyMethod
will throw an exception. I want to be able to unit test that situation. In my case the catch clause from execute method.