I would like to set up a return value
_stubRepository.Stub(Contains(null)).IgnoreArguments().Return(true);
but then in a specific test, ove
For these situations, I created a simple RinoMocks extention method to better show the intent of the stub and promote readability.
public static void OverridePrevious(this IMethodOptions options)
{
options.Repeat.Any();
}
So instead of a cryptic call like the following that may require a comment:
[SetUp]
public void Setup()
{
carStub.Stub(x => x.Model).Return("Model1");
carStub.Stub(x => x.Model).Return("Model2");
}
[Test]
public void SomeTest()
{
//Arrange
//overrides previous stubs that were setup for the Model property
carStub.Stub(x => x.Model).Return(null).Repeat.Any();
//Act
//Assert
}
You can get a more readable test that better shows the intent of the .Repeat.Any() calls:
carStub.Stub(x => x.Model).Return(null).OverridePrevious();