c# - Moq - Setup with constraint? -


i'm trying stub this:

public t getcommand<t>() t : icommand, new() 

i'm using moq (c#), , code looks this:

_mockedbusinessfactory.setup(x => x.getcommand<icommand>()); 

but there question: how deal new() constraint?

any idea?

maybe this:

var stub = new mock<icommand>(); stub.setup( //... setup stub  mockedbusinessfactory.setup(x => x.getcommand<icommand>()).returns(stub.object); 

ps. i'm not moq user


Comments