I'm currently confuse on how to mock.
I'm using Moq. To mock objects I usually write this way
var mockIRepo = new Mock<IRepo>();
However, I need to create mock object for my setup.
Option1 Is it better to mock my object which only contain properties this way?
var object = Mock.Of<Object>()
Option2 Or this way
var object = new Mock<Object>()
I've read that option 2 has setupproperties which is kinda questionable to me because I could also set the properties in option 1.
Then what is the difference? Or is there a better way?
This post helped me to understand Mock.Of<T> : Old style imperative Mock<T> vs functional Mock.Of<T>
As explained in the post, with Mock.Of<T> you're saying "Give me a mock that behaves like this" (or Mocks.Of<T> if you need to get many objects (IEnumerable)). It makes the declaration of a mock more concise.
Example with Mock<T> (returns a Mock)
Same example using Mock.Of<T> (returns an instance of the class)