c# - How do I tell RhinoMocks to return the same object passed as parameter -
i'm using rhinomock unit testing , want know how set particular method returns same object received parameter.
this interface want mock:
public interface iitemrepository { item craete(item item); }
i want set rhinomocks in such way every time create method called, mocked stub return same object passed parameter.
this test initialization method:
[testinitialize] public void crateservicewithmockrepository() { var stubrepository = mockrepository.generatestub<iitemrepository>(); // ... how set-up stubrepository described above ... // create target service unit test this.targetservice = new servicexyz(stubrepository); }
you can use do
, pass delegate execute when method called:
stubrepository.stub(r => r.create(null)).ignorearguments() .do(new func<item, item>(item => item));
Comments
Post a Comment