问题
Performing the following steps:
- Creating a default WCF Service Library project
- Creating a default Unit Test project and referencing the service library
- Creating a Fakes assembly for System in the unit test project
I was expecting there to be a type ShimFtpWebRequest
in System.4.0.0.0.Fakes. There is not. Setting the Diagnostics property to true on System.Net.Fakes emits a huge slew of warning messages mostly talking about failure to generate stubs, including for FtpWebRequest
- because those classes are sealed, are enums, and so on. I'm ok with that, and I don't care about stubs, what I want are shims. There is no message saying that it couldn't generate a shim type.
This question suggests that there are some scenarios were it is generated, as the OP uses it, but he doesn't mention anything about how he generated it, as it isn't the subject of the question.
Why doesn't Fakes generate the type ShimFtpWebRequest
?
回答1:
You need to edit the System.fakes
file that was generated to tell it to generate the class. I believe it auto ignores sealed classes.
I had the same issue as you when I tested, but then I manually told it to generate it.
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="System" Version="4.0.0.0"/>
<ShimGeneration>
<Add FullName="System.Net.FtpWebRequest"/>
</ShimGeneration>
</Fakes>
来源:https://stackoverflow.com/questions/26914058/why-doesnt-microsoft-fakes-create-shimftpwebrequest