unit testing - How to stub out a generic method definition in an interface using Microsoft Fakes in c# -
i have unit test stubs out following interface using microsoft fakes:
public interface itable { task<tableresult> retrieve(string tablereference, string partitionkey, string rowkey); }
the stub looks this:
itable table = new messagesapi.azure.fakes.stubitable() { retrievestringstringstring = delegate { tableresult tableresult = new tableresult(); return task.fromresult(tableresult); } };
this works fine. i'd change interface more generic so:
public interface itable { task<tableresult> retrieve<t>(string tablereference, string partitionkey, string rowkey) t : itableentity; }
question how stub new version of interface out? i'm having trouble getting syntax right.
any ideas?
you set behavior following:
var table = new messagesapi.azure.fakes.stubitable(); table.retrieveof1stringstringstring<itableentity>( (tablereference, partitionkey, rowkey) => { tableresult tableresult = new tableresult(); return task.fromresult(tableresult); });
Comments
Post a Comment