Setup () vs SetupGet ()

What is the difference between SetupGet () and Setup () methods for MOQ?

+46
moq
Apr 23 2018-11-23T00:
source share
2 answers

Setup () can be used to mock a method or property.

SetupGet () is specifically designed to bully the recipient of a property. Took a quick look at the Moq source code, and it looks like if you use Setup () on the getter properties, it is called SetupGet (). Thus, in this case, there is probably a more personal preference as to whether you want to be more explicit and use SetupGet () instead of Setup ().

Of course, my knowledge of Moq is limited, so I don’t know if there are any special cases where you will need to use SetupGet () via Setup ().

+51
Apr 25 2018-11-11T00:
source share

SetupGet works when you try to make fun of a read-only property

+12
02 Oct 2018-11-11T00:
source share



All Articles