Rhino mocks using AssertWasNotCalled

I made the next stub

_Service.Stub(s => s.Login(Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<int>.Is.Anything, out ggg)).OutRef(55); 

the last parameter is an out parameter of type int .

I want to do the following assert

  _Service.AssertWasNotCalled(s => s.Login(Arg<string>.Is.Anything, Arg<string>.Is.Anything,Arg<int>.Is.Anything , ??????? )); 

But how do I mark out parameter here?

+4
source share
2 answers

Just use:

 _Service.AssertWasNotCalled(s => s.Login( Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<int>.Is.Anything , out Arg<int>.Out(10).Dummy )); 

The value passed to the Out method does not matter (. The Dummy call is important).

+6
source

A mock statement usually applied to mocks not stubs. So you can rewrite the code to have the following setting

 _Service.Expect(s => s.Login(Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<int>.Is.Anything, out ggg)).OutRef(55).Repeat.Never(); 

And mke check in Assert test part

 _Service.VerifyAllExpectations(); 
+3
source

All Articles