In my unit test instead of IgnoreArguments i want to use some partial matching of arguments in rhino mocks testing. How to do that?
Thanks, John
// arrange
var fooStub = MockRepository.GenerateStub<IFoo>();
// act
fooStub.Bar("arg1", "arg2", 3);
// assert
fooStub.AssertWasCalled(
x => x.Bar(
Arg<string>.Is.Equal("arg1"),
Arg<string>.Is.Anything,
Arg<int>.Is.Equal(3))
);
You can use constraints. You ignore the arguments passed into the expectation call and then add explicit constraints for each argument. An example from the Rhino Mocks documentation:
Expect.Call(view.Ask(null,null)).IgnoreArguments().Constraints(
Is.Anything(),
Is.TypeOf(typeof(SomeType))).Return(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With