mardi 26 avril 2016

Issue creating Shim with Microsoft Fakes

While creating a set of unit tests I had the need to works with Shims. Using Microsoft Fakes, I added a "Fakes" assembly for the external DLL that I'm referencing in my test.

There is a Fakes folder created in visual studio with a .fake file for the RagePluginHook that I'm working with. However, my project no longer can compile with the Fakes file existing.

RagePluginHook.dll failed to load properly Could not load type 'Rage.PoolHandle' from assembly 'RagePluginHook, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the method '.ctor' has no implementation (no RVA). APHCommonTest C:\Users\User\Projects\RAGEObjectPlacer\APHCommonTest\Fakes\RagePluginHook.fakes

The library Im referencing has a static class and static method that I'm looking to shim, but I'm unable to resolve my error.

In looking online, it looks like the error is related to C++ extern keyword being used. Since the referenced project isn't opened source, I'm completely at a loss.

The constructor that its complaining about has documentation available online @ RAGE Documentation PoolHandler Constructor

Is there a way that I can create shims with the external reference that I'm working with? I noticed options for the construction of the shim's arguments, however the project refuses to build even without using the Shim's logic.

Test File

public class ActionBoundKeyShimmedTest
{
    public class BaseState
    {
        [Fact]
        public void IsControllerButtonPressed()
        {
            using (ShimsContext.Create())
            {
                Rage.Fakes.ShimGame.IsControllerConnected
                     = () =>
                     {
                         //Implement shim logic
                     };

            } 

        }
    }
}

RagePluginHook.fakes

<Fakes xmlns="http://ift.tt/1nzIu3W">
  <Assembly Name="RagePluginHook" Version="0.0.0.0"/>
</Fakes>

Aucun commentaire:

Enregistrer un commentaire