Moq an indexed property and use the index value in the return/callback

后端 未结 2 1301
后悔当初
后悔当初 2021-01-18 05:38

I want to moq a property that has an index, and I want to be able to use the index values in the callback, the same way you can use method arguments in the callback for moq\

2条回答
  •  天命终不由人
    2021-01-18 06:14

    The method SetupSet takes a plain delegate, not an expression tree of type Expression<...> like many other Moq methods.

    For that reason Moq cannot see that you used It.IsAny. Instead, It.IsAny is called (not what we want) and Moq sees its return value only which happens to be default(int), or 0.

提交回复
热议问题