Hi, I would like to request a Rhino Mocks feature be ported to Moq that allows parameter matching from a collection when setting up calls.
// IEnumerable<TValue> mock.Setup(x => x.Echo(It.IsIn(Enumerable.Range(1, 5)))).Returns(1);
// Variadic params mock.Setup(x => x.Echo(It.IsIn(1, 2, 3, 4, 5))).Returns(1);
// As well as the inverses mock.Setup(x => x.Echo(It.IsNotIn(Enumerable.Range(1, 5)))).Returns(1); mock.Setup(x => x.Echo(It.IsNotIn(1, 2, 3, 4, 5))).Returns(1);
At work I have done this by hand more times than I can remember so I figured I may as well submit a patch and make it official! A patch for this is attached (includes tests and documentation). Cheers, Rich
- moq-it-isin-isnotin.patch 7.11KB
Comment #1
Posted on Sep 5, 2012 by Quick GiraffeHi Rich! Any chance you could fork moq4 over at github and send a pull request with this change?
Comment #2
Posted on Sep 12, 2012 by Grumpy HorseComment #3
Posted on Sep 13, 2012 by Quick MonkeyMerged!
Thanks! :-)
Status: Fixed
Labels:
Type-Defect
Priority-Medium