我有一个单元测试,使用Microsoft Fakes抽出以下接口:
public interface ITable
{
Task<TableResult> Retrieve(string tableReference, string partitionKey, string rowKey);
}
存根看起来像这样:
ITable table = new MessagesAPI.Azure.Fakes.StubITable()
{
RetrieveStringStringString = delegate
{
TableResult tableResult = new TableResult();
return Task.FromResult(tableResult);
}
};
这很好。但是我想将接口更改为更通用,如下所示:
public interface ITable
{
Task<TableResult> Retrieve<T>(string tableReference, string partitionKey, string rowKey)
where T : ITableEntity;
}
问题是如何将这个新版本的接口存根?我在正确使用语法方面遇到困难。
有任何想法吗?
您将行为设置为以下内容:
var table = new MessagesAPI.Azure.Fakes.StubITable();
table.RetrieveOf1StringStringString<ITableEntity>(
(tableReference, partitionKey, rowKey) =>
{
TableResult tableResult = new TableResult();
return Task.FromResult(tableResult);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句