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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -