Need help to understand Moq better

后端 未结 2 1502
无人及你
无人及你 2020-12-22 16:40

I\'ve been looking at the Moq documentation and the comments are too short for me to understand each of things it can do.

The first thing I don\'t get is It.Is

2条回答
  •  没有蜡笔的小新
    2020-12-22 17:09

    If you don't care about the exact value of a property, it's far better to use .IsAny because you are being explicit about the fact that the exact value is not important. If you hardcode it as "abc", then it is not clear if your code you are testing depends on starting with "a" or ending with "c" or being 3 chars long, etc. etc.

提交回复
热议问题