【发布时间】:2016-03-30 12:19:04
【问题描述】:
在设置 OOB 默认 Visual Studio 2013 Update 5 项目时,没有测试设置,使用 4.6.1 的目标框架,将 Fakes 程序集添加到系统并设置以下 ShimGenerations:
mscorlib.fakes:
<ShimGeneration>
<Clear/>
<Add FullName="System.Collections.ReadOnlyCollectionBase"/>
<Add FullName="System.ApplicationException"/>
<Add FullName="System.IO.Path"/>
<Add FullName="System.Security.SecureString"/>
<Add FullName="Microsoft.Win32.Registry"/>
<Add FullName="Microsoft.Win32.RegistryKey"/>
<Add FullName="System.Activator"/>
<Add FullName="System.Convert"/>
<Add FullName="System.Version"/>
<Add FullName="System.StringComparer"/>
<Add FullName="System.Threading.Thread"/>
</ShimGeneration>
System.fakes:
<ShimGeneration>
<Clear/>
<Add FullName="System.Text.RegularExpressions.Regex"/>
<Add FullName="System.Diagnostics.FileVersionInfo"/>
<Add FullName="System.Diagnostics.Process"/>
<Add FullName="System.Net.CookieContainer"/>
<Add FullName="System.Net.FtpWebRequest"/>
<Add FullName="System.Net.FtpWebResponse"/>
<Add FullName="System.Net.IPAddress"/>
<Add FullName="System.Net.Dns"/>
<Add FullName="System.Net.Mail.SmtpClient"/>
<Add FullName="System.Net.Mail.MailMessage"/>
<Add FullName="System.Net.NetworkInformation.Ping"/>
<Add FullName="System.Net.NetworkInformation.PingReply"/>
<Add FullName="System.Net.NetworkInformation.PingException"/>
<Add FullName="System.Net.HttpWebRequest"/>
<Add FullName="System.Net.HttpWebResponse"/>
<Add FullName="System.Net.WebHeaderCollection"/>
<Add FullName="System.Net.ServicePoint"/>
<Add FullName="System.Net.NetworkInformation.NetworkInterface"/>
<Add FullName="System.Net.Sockets.TcpClient"/>
<Add FullName="System.Net.Sockets.UdpClient"/>
<Add FullName="System.Net.Sockets.Socket"/>
<Add FullName="System.Net.WebRequestMethods"/>
<Add FullName="System.Net.WebRequest"/>
<Add FullName="System.Uri"/>
</ShimGeneration>
出现以下错误:
'System.Net.Sockets.SocketClientAccessPolicyProtocol' 已过时:'此 API 支持 .NET Framework 基础结构,不能直接从您的代码中使用。'
[一些路径\TestFakes\UnitTestProject1\obj\Debug\Fakes\s\f.csproj] 一些路径\TestFakes\UnitTestProject1\f.csGENERATEFAKES:错误:项目编译失败,退出代码为 1
这似乎只发生在此配置中。
我不确定如何解决这个问题,因为我需要拦截大部分 .NET 框架调用。
【问题讨论】:
-
GSerg - 我通常会同意你的观点,但它发生在假货的产生期间。我的示例中没有涉及任何代码。我在项目中没有单元测试或代码。它只是一个空的测试类和空的测试方法。我基本上是在构建一个空项目。我在下面发布了一个答案,但它非常笨拙,对我来说这是不可接受的。如果 MS 对此工具有更好的支持,那么应该有更好的方法来识别这些存在假货的问题区域。
标签: c# .net microsoft-fakes .net-4.6.1