c# - Using Moq for Generic methods -



c# - Using Moq for Generic methods -

totally simple situation, can't create work. running issue using moq mock generic method (in case, on ninject kernel interface):

t get<t>();

i set mock object:

mock<ikernel> mockkernel = new mock<ikernel>(); mockkernel.setup(x => x.get<igetuserquery>()).returns(new getuserquery());

at runtime next exception:

expression references method not belong mocked object: x => x.get<igetuserquery>(new[] { })

any thought why it's throwing this? i've mocked generics in moq before without problem... there cases in generic mocking isn't supported? seems straightforward case. wrinkle igetuserquery in turn inherits genericized type:

igetuserquery : icommand<userqueryinput, userqueryoutput>

i don't see creating problem because generic types implementation of icommand staticly defined igetuserquery, uncertainty confusing moq.

thanks in advance

the problem t get<t> () isn't method defined in ikernel interface, extension method defined here.

why trying mock t get<t> () in first place? interaction ioc container should absolutely minimal, @ toplevel "entry point" system.

c# generics mocking moq

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -