While some may argue that this is getting to detailed in a test, from my stand point, where many tests are more insurance against others changing things and not realizing the impact, I might have part of my assert check that the stored procedure in a 'case' statement I'm testing is what I expect to be called:
Isolate.Verify.NonPublic.Property.WasCalledSet(fakeCmd, "CommandText").WithArgument("spName");
Now it would seem to me, that because CommandText is actually a public property of IDbCommand that it should be pretty straight-forward to support a feature that allows the following:
Isolate.Verify.Property.WasCalledSet<SqlCommand>(() => fakeCmd.CommandText).WithArgument("spName");
This will in cases where it's a more 'custom' property, to have type checking and easier refactoring. Obviously the original method needs to be kept for non-public properties.
Here's an example of the code that I would be testing against:
private void DataPortal_Fetch(Criteria criteria)
{
string cmdText = null;
switch(criteria.FetchType)
{
case FetchType.ActiveOnly:
cmdText = "FetchActive";
break;
case FetchType.DeactivatedOnly:
cmdText = "FetchDeactivated";
break;
default:
cmdText = "FetchAll";
break;
}
//Remainder of DataPortal_Fetch code which goes out to
//database and makes the cmd.ExecuteReader call.
}