Moling System.dll

徘徊边缘 提交于 2020-01-21 08:59:45

问题


I need to unit test a method that is using the System.Net.WebClient in the System.dll. I tried to Mole the System.dll, but when I tried to compile the project to add references to the System.dll mole, I got a bunch of errors like the following:

Error 2

'System.Net.Moles.SFileWebResponse.Dispose(bool)': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 251374 33 DGALib.IO.Tests

Error 3

'System.Net.Moles.SFileWebResponse.SupportsHeaders': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 251575 30 DGALib.IO.Tests

Error 4

'System.Net.Moles.SHttpWebResponse.Dispose(bool)': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 255264 33 DGALib.IO.Tests

Error 5

'System.Net.Moles.SHttpWebResponse.SupportsHeaders': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 255465 30 DGALib.IO.Tests

Error 6

'System.Net.Moles.SWebResponse.Dispose(bool)': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 303123 33 DGALib.IO.Tests

Error 7

'System.Net.Moles.SWebResponse.SupportsHeaders': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 303324 30 DGALib.IO.Tests

Error 8

'System.Net.Moles.SFileWebResponse.Dispose(bool)': no suitable method found to override [C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\s\m.g.csproj] C:\DGALibrary\DGALib.IO.Tests\m.g.cs 251374 33 DGALib.IO.Tests

And finally

Error 28

The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @C:\DGALibrary\DGALib.IO.Tests\obj\x86\Debug\Moles\moles.args" exited with code -1002. DGALib.IO.Tests

Are we not able to mole system.dll?


回答1:


try this

<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
  <Assembly Name="System" ExportedTypes="true" ReflectionOnly="true"/>  
</Moles>



回答2:


I'm new to Pex/Moles so I can't provide you with an answer as to why the errors are occurring. However, so long as the errors aren't for types you actually need to Mole you can resolve your problem by editing the system.moles file to restrict the types to mole to just the ones you care about.



来源:https://stackoverflow.com/questions/8144653/moling-system-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!