Using Rhino Mocks to mock an out parameter, which is created within the method I am testing

Try the “OutRef” option. It accepts a params object[] that defines the result for each out parameter. Since you’ve only got one, you only need one result. Here’s a quick mock-up of what I tried that should work in your situation:

var foo = MockRepository.GenerateStub<IFoo>();
var viewModel = new LoginViewModel();
User temp;
foo.Stub(f => f.IsLoginValid(viewModel, out temp)).OutRef(new User()).Return(false);

User outparam;
Assert.IsFalse(foo.IsLoginValid(viewModel, out outparam));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)