c# - Mocking session state with Rhino mocks -
i trying perform test operation on complex methods handles complex objects. in uses sessionmanager class customer class properties , handles session context stuff.
i have below code trying mock sessionstate , override value returned promotiondto property returned sessionmanager class.
sessionmanager sessionstub = mockrepository.generatestub<sessionmanager>( mockobjectfactory.getmockhttpsessionstate()); var dto = new promotionparamsdto(store.defaultadcode, membershiptypefromresult.membershiptype.id, offercodes, true); sessionstub.stub(x => x.promotiondto).return(dto);
i facing below error @ last line trying stub value
invalid call, last call has been used or no call has been made (make sure calling virtual (c#) / overridable (vb) met
@ rhino.mocks.lastcall.getoptions[t]() @ rhino.mocks.rhinomocksextensions.expect[t,r](t mock, function`2 action) @ rhino.mocks.rhinomocksextensions.stub[t,r](t mock, function`2 action) @ bluefield.test.membershippromo.membershipinfoservicestest.checkandrunpromoformembershiptypetest()
i using mockobjectfactory implementation here http://codeverge.com/asp.net.free-for-all/mocking-httpcontext-object/36423
kindly me here, thanks.
nevermind, had changed property trying stub overridable , set values directly fix problem.
Comments
Post a Comment