Why doesn't Microsoft Fakes create ShimFtpWebRequest?

702 views Asked by At

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

There are 1 answers

1
TyCobb On BEST ANSWER

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>