You could have a look at
NUnitForms[
^] or change myMethod to take a flag to say whether or not to show the message e.g.
public int myMethod(bool ShowMessage = true)
{
int retVal = 1;
if (ShowMessage)
retVal = (MessageBox.Show("Sure?", "Title", MessageBoxButtons.YesNo) == DialogResult.Yes) ? 1 : 0;
return retVal;
}
Note however, changing the application to suit the test in this way isn't recommended.