Why doesn't moq setup all properties by default?

一曲冷凌霜 提交于 2019-12-11 06:09:48

问题


I understand that in Moq, you need to set up properties before you can assign values. My question is why doesn't Moq just allow you to set properties by default without having to "set" them up.


回答1:


That is a question for the developer. Till then you can take a look at the Quickstart and see if it helps answer your question.

mock.SetupAllProperties(); which stubs all properties on a mock.

My guess would be that not all mocks would possess properties so making the framework attempt to look up and setup properties would not make for an efficient API. the opt-in option of setting it up if needed seems like an optimal approach.



来源:https://stackoverflow.com/questions/42630709/why-doesnt-moq-setup-all-properties-by-default

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!