mercredi 4 mai 2016

Mock.Of

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?

Aucun commentaire:

Enregistrer un commentaire