moq icon indicating copy to clipboard operation
moq copied to clipboard

Semantic error in unit test MatchesIsNotInEnumerable()?

Open praeceptum opened this issue 1 year ago • 1 comments

Regarding the class Moq.Tests.MatchersFixture, given that the setups in the unit test method MatchesIsInVariadicParameters() are:

mock.Setup(x => x.Echo(It.IsIn(1, 2, 3, 4, 5))).Returns(1);
mock.Setup(x => x.Echo(It.IsIn(6, 7, 8, 9, 10))).Returns(2);

then the ranges in MatchesIsNotInEnumerable():

mock.Setup(x => x.Echo(It.IsNotIn(Enumerable.Range(1, 5)))).Returns(1);
mock.Setup(x => x.Echo(It.IsNotIn(Enumerable.Range(6, 10)))).Returns(2);

were probably meant to be:

mock.Setup(x => x.Echo(It.IsNotIn(Enumerable.Range(1, 5)))).Returns(1);
mock.Setup(x => x.Echo(It.IsNotIn(Enumerable.Range(6, 5)))).Returns(2);

since the signature is Range(int start, int count), not Range(int start, int end).     The same is probably true for MatchesIsInEnumerable() given the ranges in MatchesRanges(), except that the latter is using an exclusive range for the second sequence.

Back this issue Back this issue

praeceptum avatar May 21 '24 06:05 praeceptum

Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.

github-actions[bot] avatar May 08 '25 01:05 github-actions[bot]