Can not instantiate proxy…Could not find a parameterless constructor

百般思念 提交于 2019-12-04 23:51:23

MOQ is good for mocking interfaces, but does not work so well with concrete classes. So instead of mocking concrete class, ask for the inteface:

var userStore = new Mock<IUserStore<PreRegistrationMVC.Models.ApplicationUser>>();

Also ApplicationUser should be POCO, so no need to mock it, just create its instance without MOQ and use in tests.

I had this problem. I had written...

var x = new Mock<Concrete>();

... instead of ...

var x = new Mock<IConcrete>();

You can try referring Mock behavior,as shown below

Mock<testClass>(MockBehavior.Strict, new object[] {"Hello"}); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!