You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on an addin for the VBE - Rubberduck. We are working on getting everything under unit tests, but Moq doesn't support extension methods. Rather than implementing an interface between the VBE and RD just to stick our extension methods in, I figured I would write a patch for Moq that would allow interface methods. Looking through the project, this is the relevant code:
private static void ThrowIfNotMember(Expression setup, MethodInfo method)
{
if (method.IsStatic)
{
throw new NotSupportedException(string.Format(
CultureInfo.CurrentCulture,
Resources.SetupOnNonMemberMethod,
setup.ToStringFixed()));
}
}
It is called just twice - in internal static MethodCallReturn<T, TResult>() and internal static MethodCall<T> Setup<T>().
I didn't dare touch this code because I don't know what bugs this is preventing. Could someone who knows explain what I would need to do to fix this?
You can't mock extension methods because they are static, and you can't
override a static method call by inheriting its declaring class.
On Sat, Jul 11, 2015 at 1:16 AM Hosch250 notifications@github.com wrote:
I am working on an addin for the VBE - Rubberduck https://github.com/rubberduck-vba/Rubberduck. We are working on getting
everything under unit tests, but Moq doesn't support extension methods.
Rather than implementing an interface between the VBE and RD just to stick
our extension methods in there, I figured I would write a patch for Moq
that would allow interface methods. Looking through the project, this is
the relevant code:
private static void ThrowIfNotMember(Expression setup, MethodInfo method)
{
if (method.IsStatic)
{
throw new NotSupportedException(string.Format(
CultureInfo.CurrentCulture,
Resources.SetupOnNonMemberMethod,
setup.ToStringFixed()));
}
}
It is called just twice - in internal static MethodCallReturn<T,
TResult>() and internal static MethodCall Setup().
I didn't dare touch this code because I don't know what bugs this is
preventing. Could someone who knows explain what I would need to do to fix
this? It appears to have been committed just 24 days ago 4d0cb13
.
—
Reply to this email directly or view it on GitHub #189.
I am working on an addin for the VBE - Rubberduck. We are working on getting everything under unit tests, but Moq doesn't support extension methods. Rather than implementing an interface between the VBE and RD just to stick our extension methods in, I figured I would write a patch for Moq that would allow interface methods. Looking through the project, this is the relevant code:
It is called just twice - in
internal static MethodCallReturn<T, TResult>()
andinternal static MethodCall<T> Setup<T>()
.I didn't dare touch this code because I don't know what bugs this is preventing. Could someone who knows explain what I would need to do to fix this?
Edit:
After a bit of research, I found the commit it was introduced in.
The text was updated successfully, but these errors were encountered: