Export to GitHub

moq - issue #338

Feature request (with patch): It.IsIn(..), It.IsNotIn(...)


Posted on Apr 2, 2012 by Grumpy Horse

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

Attachments

Comment #1

Posted on Sep 5, 2012 by Quick Giraffe

Hi 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 Horse

Done - https://github.com/Moq/moq4/pull/27

Comment #3

Posted on Sep 13, 2012 by Quick Monkey

Merged!

Thanks! :-)

Status: Fixed

Labels:
Type-Defect Priority-Medium