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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -