Possible Duplicate:
How to throw a SqlException(need for mocking)
I want to mock the throwing of SqlException
when ExecuteNonQuery
is executed;
System.Data.SqlClient.Moles.MSqlCommand.AllInstances.ExecuteNonQuery =
(command) =>
{
throw new MSqlException();
};
This doesn't work as the compiler complains MSqlException
doesn't derive from Exception
. Am I going about this the wrong way, will I need to wrap ExecuteNonQuery
in my code to achieve this?