What happen when two setup intersect or overlap if you prefer.
For example, in the below scenario the setup overlap because obviously "aSpecificString"
is also considered as any string.
Interface ISomeInterface
{
int SomeMethod(string param);
}
[TestMethod]
public void SomeClass_ShouldBehaveProperly_GivenSomeScenario()
{
var mock = new Mock<ISomeInterface>(MockBehavior.Strict);
mock.Setup(m => m.SomeMethod("aSpecificString"))
.Returns(100);
mock.Setup(m => m.SomeMethod(It.IsAny<string>()))
.Returns(0);
/*the rest of the test*/
}
I wonder what happen when it intersect.
Does it throw an exception or does it fail to detect the overlap and use the first matching setup in the order they were added?
I think it's best to avoid overlapping setup.
Aucun commentaire:
Enregistrer un commentaire