【问题标题】:How to shim System.Environment?如何填充 System.Environment?
【发布时间】:2020-01-30 13:39:27
【问题描述】:

我正在尝试填充 System.Environment:

Dim args = {"a", "b", "c", "d", "e")}
System.Fakes.ShimEnvironment.GetCommandLineArgsGet =
Function() As String()
   Return args
End Function

我引用了 C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\PublicAssemblies\Microsoft.QualityTools.Testing.Fakes.dll

我的项目的 Fakes 文件夹中有以下文件:

mscorlib.fakes:

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="mscorlib" Version="4.0.0.0"/>
</Fakes>

System.fakes:

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="System" Version="4.0.0.0"/>
</Fakes>

但是我得到了编译错误:

错误 BC30456:“ShimEnvironment”不是“System.Fakes”的成员。

如何填充 System.Environment?

【问题讨论】:

    标签: .net-4.5 visual-studio-2019 shim


    【解决方案1】:

    按照https://social.msdn.microsoft.com/Forums/vstudio/en-US/b49e9f5d-0e57-46b1-8ced-f3231db5e813/cannot-find-a-shim-for-systemenvironmentmachinename-etc?forum=vsunittest 中的建议,我必须将以下内容放入 mscorlib.fakes:

      <ShimGeneration>
        <Add FullName="System.Environment"/>
      </ShimGeneration>
    

    【讨论】:

      猜你喜欢
      • 2013-11-30
      • 2012-02-15
      • 2013-04-16
      • 1970-01-01
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多