Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我可以伪造HttpContent.ReadAsAsync?_C#_.net_Visual Studio 2012_Microsoft Fakes - Fatal编程技术网

C# 我可以伪造HttpContent.ReadAsAsync?

C# 我可以伪造HttpContent.ReadAsAsync?,c#,.net,visual-studio-2012,microsoft-fakes,C#,.net,Visual Studio 2012,Microsoft Fakes,是否可以在Visual Studio 2012中创建在帮助下实现的存根?如果是,如何在VS2012中存根?HttpContent.ReadAsAsync。原因是,这不是一个虚拟方法,而是一个扩展方法。只能存根虚拟接口/类方法。在VS2012中无法存根HttpContent.ReadAsAsync。原因是,这不是一个虚拟方法,而是一个扩展方法。只有虚拟接口/类方法可以被存根。为了将来的搜索 存根只能覆盖其自身实例的方法。您可以存根任何公开可以重写的成员的类型,无论是抽象的、接口的还是类的 在这种情

是否可以在Visual Studio 2012中创建在帮助下实现的存根?如果是,如何在VS2012中存根?

HttpContent.ReadAsAsync。原因是,这不是一个虚拟方法,而是一个扩展方法。只能存根虚拟接口/类方法。

在VS2012中无法存根HttpContent.ReadAsAsync。原因是,这不是一个虚拟方法,而是一个扩展方法。只有虚拟接口/类方法可以被存根。

为了将来的搜索

存根只能覆盖其自身实例的方法。您可以存根任何公开可以重写的成员的类型,无论是抽象的、接口的还是类的

在这种情况下,可以使用垫片:

ShimHttpContent.ReadAsAsyncOf1<TypeYouWant> = *something matching the method signature*

它提供的附加优势是,现在可以指定每种类型的行为。这是使用垫片的最有效原因之一。

为了将来的搜索

存根只能覆盖其自身实例的方法。您可以存根任何公开可以重写的成员的类型,无论是抽象的、接口的还是类的

在这种情况下,可以使用垫片:

ShimHttpContent.ReadAsAsyncOf1<TypeYouWant> = *something matching the method signature*
它提供的附加优势是,现在可以指定每种类型的行为。这是使用垫片的最有效原因之一