Fix for "cannot convert from 'method group' to 'string'"

1,364 views
Skip to first unread message

Chris Missal

unread,
Dec 26, 2012, 10:48:49 PM12/26/12
to moq...@googlegroups.com
This error comes up quite a bit in the mailing list as well as on Stackoverflow. Basically, somebody forgets to invoke the method.

Instead of:

    mock.Verify(foo => foo.Submit(), Times.Once());

Somebody might accidentally write it as:

    mock.Verify(foo => foo.Submit(), Times.Once);

Note the missing parentheses.


Is it worthwhile to create an overload that accepts Func<Times> in addition to Times? Then have that Verify method simply delegate to Verify like so:

    public void Verify(Expression<Action<T>> expression, Func<Times> times)
    {
        Verify(expression, times());
    }


Good idea? Bad idea? I think the shortcut/band-aid could save lots of people some time.

--
Chris Missal

Daniel Cazzulino

unread,
Dec 27, 2012, 12:06:39 AM12/27/12
to moqdisc
great idea!


/kzu

--
Daniel Cazzulino


Reply all
Reply to author
Forward
0 new messages