Search code examples
c#.netunit-testingmicrosoft-fakes

Microsoft Fakes can't find the `ICollection` and `IDictionary` interfaces


MS Visual Studio 2015 Enterprise.

I am learning Microsoft Fakes Framework. I have two assemblies AcDbMng.dll and AcMng.dll are written by other company (Autodesk). They use .Net Framework 2.0. I create new Unit Test Project, add these assemblies into my project, and through their context menu call the "Add Fakes Assembly". Now I launch my project building and get 128 errors... For example:

It wasn't succeeded to find type or a name of a name space of "ICollection" (perhaps, there is no directive of using or an assembly reference). [c:\users\andrey\documents\visual studio 2015\Projects\msfakes\obj\Debug\Fakes\adm\f.csproj] msfakes c:\users\andrey\documents\visual studio 2015\Projects\msfakes\f.cs 206092

It wasn't succeeded to find type or a name of a name space of "IDictionary" (perhaps, there is no directive of using or an assembly reference). [c:\users\andrey\documents\visual studio 2015\Projects\msfakes\obj\Debug\Fakes\adm\f.csproj] msfakes c:\users\andrey\documents\visual studio 2015\Projects\msfakes\f.cs 206119

The modifier "override" is not valid for this item. [c: \ users \ andrey \ documents \ visual studio 2015 \ Projects \ msfakes \ obj \ Debug \ Fakes \ adm \ f.csproj] msfakes c: \ users \ andrey \ documents \ visual studio 2015 \ Projects \ msfakes \ f. cs 206119

Such error messages are not clear for me. I tried to change the target .Net Framework platform: .Net 4.6 and .Net 3.5, but I get the same messages.

ICollection, IDictionary, modifier "override"... I don't understand, what relation they have to these assemblies, because they are defined in the platform assemblies instead of AcDbMng.dll and AcMng.dll.

Anybody has idea about such behaviour?

UPD

Maybe Autodesk uses own interfaces with the same names and I am to add some additional assemblies of AutoCAD for Microsoft Fakes Framework using?

If I generate the fake only for AcMng.dll then I haven't errors. But if I generate the fake also for AcDbMng.dll then I get these problems. Also, at this case in the Solution Explorer I see the AcMgd.17.2.0.0.Fakes appeared, but I don't see something like AcDbMgd.17.2.0.0.Fakes:

enter image description here

UPD2

It is possible to download the AcDbMgd.dll file from here.

UPD3

Theme is closed. More detailed info about the fakes-format is here.


Solution

  • You might try editing the AcDbMgd.fakes and AcMgd.fakes files with something like

    <Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
      <Assembly Name="AcDbMgd" Version="..."/>
      <StubGeneration>
        <Clear/>
      </StubGeneration>
      <ShimGeneration>
        <Clear/>
        <Add FullName="your class of concern"/>
      </ShimGeneration>
    </Fakes>
    

    You're restricting the classes that get generated and explicit deciding which classes do. When I run into problems like you're having, if I limit the classes that get generated, I have better luck. It's hard to give a more specific answer without being able to recreate it myself.