Sounds fair. The last comment is the best IMO.
What if you could sequence just by calling .Returns (or .Throws) more than once? So we'd have overwrite behavior for the first call to .Returns, but not successive ones:
mock.Setup(x => x.Do()).Returns(2);
// overwrites the previous one, current behavior:
mock.Setup(x => x.Do()).Returns(5);
// sequencing
mock.Setup(x => x.Do())
.Returns(2)
.Returns(3)
.Throws<InvalidOperationException>();
I do like the shortcut for returning many values in order:
// essencially the same as above call
mock.Setup(x => x.Do())
.Returns(2, 3)
.Throws<InvalidOperationException>();
Not sure if a simple overload receiving T, params T[] sequence, is OK or if a more explicit method name such as ReturnsOrdered is better... thoughts?
/kzu
--
Daniel Cazzulino | Developer Lead | XML MVP | Clarius Consulting |
+1 425.329.3471