unit testing - Rhino Mock Expect.Call() actually calls the method not only create an expectation -


i want test if method has been called in test.

my problem when want create expectations not working thought. next line runs method, not create expectation:

expect.call(() => mockedservice.methodthatiexpecttorun(params)); 

there way:

mockedservice.expect((s=> s.methodthatiexpecttorun(params))); 

but runs method, not creates expectation fulfilled test.

and line asserts if method not called calls method, not checks whether called.

mockedservice.assertwascalled(s=> s.methodthatiexpecttorun((params))); 

additional info: methodthatiexpecttorun returns void

for prgmtc's comment:

iservice mockedservice = mockrepository.generatepartialmock<service>(mockedrepository_1, ..., mockedrepository_n); 

usually when have partialmock that's calling real method when setting stub or expect, means virtual keyword missing on method.

make sure service.methodthatiexpecttorun virtual.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -