Reputation: 9842
In Moq
, I know that there is SetupSequence
for setting sequential usage of a function and there is SetupGet
for setting a value for a property.
However I need to set a property in a sequential way.
Is there a way for setting up sequential get in Moq
?
Note: I did not write the interface or the service which I am mocking, therefore I cannot change it.
Upvotes: 3
Views: 1392
Reputation: 236208
Sequencing return values with SetupSequence
works for property getters as well :
mock.SetupSequence(m => m.PropertyName).Returns(1).Returns(2).Returns(3);
Note: you can use Setup
instead of SetupGet
, because Moq checks whether the body of given lambda expression is a property and calls SetupGet
internally [Source Code]. So the only benefit you have is skipping this internal check.
Upvotes: 6