tags:

views:

51

answers:

1

I am trying to use VerifySet with Moq to check the number of times a setter on a collaborating Object is being called. But when I put in the Times portion of the call I get an error that the assignment operator is not valid in an expression tree.

mockTimer.VerifySet(timer => timer.Prop = value); //Works fine
mockTimer.VerifySet(timer => timer.Prop = value, Times.Once); //Compile Error
+1  A: 

You need to call the function Times.Once():

mockTimer.VerifySet(timer => timer.Prop = value, Times.Once()); 
Darin Dimitrov