c# - Rhino Mocks: How can I mock out a method that transforms its input? -


i have data access object transactiondao. when call transactiondao.save(transaction) setting transaction.issaved=true flag (this simplification actual thing i'm trying not quite banal). when mocking transactiondao rhinomocks how can indicate should transform input?

ideally write this:

expect.call(delegate {dao.save(transaction);}).override(x => x.issaved=true); 

does know how this?


though got hint how answer specified below actual type signature off, have this: because of mark ingram posted, seems best answer, though nobody's explicitly said it, this:

public delegate void fakesave(transaction t); ... expect.call(delegate {dao.save(t); }).do( new fakesave(delegate(transaction t2) { t.issaved = true; })); 

gorge,

the simplest solution, found, applied question following:

expect.call(() => dao.save(transaction))     .do(new action<transaction>(x => x.issaved = true)); 

so don't need create special delegate or else. use action in standard .net 3.5 libraries.

hope help. frantisek


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -