1

I want to use fakes(shims) to mock nj4x library. I followed the guidelines here to generate them: https://msdn.microsoft.com/en-us/library/hh549174.aspx

However fakes for some classes are not generated. I tried solutions suggested here: Shims are not generated for .NET methods

Shims are not generated for .NET methods

but still not working. When I build, I get this warning:

Cannot generate shim for nj4x.Strategy: Could not resolve assembly 'NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'. Are you missing an assembly reference?.

My assembly file for now is

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/"
       Diagnostic="true">
  <Assembly Name="nj4x" Version="2.5.6.0"/>
  <ShimGeneration>
    <Clear/>
    <Add Namespace="nj4x!"/>
    <Add Namespace="nj4x.metatrader!"/>
  </ShimGeneration>
</Fakes>

I have tried several other thins too but not working. I am really stuck here.

Community
  • 1
  • 1
Usama Aslam
  • 437
  • 7
  • 18
  • Without downloading and trying it, my guess is that the '!' is pulling in some classes that are dependent on other assemblies. You might try only generating a Shim for a specific class (and only the one class). If that works, slowly add additional classes. – doobop Dec 22 '16 at 03:08
  • I have tried – Usama Aslam Dec 22 '16 at 06:00
  • But does not work. – Usama Aslam Dec 22 '16 at 06:02
  • @doobop The exclamationmark means "a class named exactly this". So Usama expects the nj4x namespace to contain a type called metatrader. He also expects a type in the global namespace called nj4x, which is clearly incorrect. – TamaMcGlinn Jan 16 '19 at 09:50

1 Answers1

0

I don't really know why but once I add fakes for NLog, fakes for required classes of nj4x are generated.

Usama Aslam
  • 437
  • 7
  • 18