jozefizso / SystemWrapper

.NET library for easier testing of system APIs.
Microsoft Public License
175 stars 62 forks source link

Can not cast between SystemWrapper.Microsoft.Win32.IRegistryKeyWrap and SystemInterface.Microsoft.Win32.IRegistryKey #2

Closed theshadow closed 9 years ago

theshadow commented 9 years ago

I'm honestly at a loss at how to get this to work per this example http://www.rhyous.com/2011/11/04/unit-testing-registry-access-with-rhinomocks-and-systemwrapper/ because nothing I do works.

// this is an instance of IRegistryKeyWrap and it can not 
// be casted to IRegistryKey
var registryKey = new RegistryWrap().LocalMachine; 
jozefizso commented 9 years ago

This works.

<packages>
  <package id="SystemWrapper.Interfaces" version="0.7.0.0" targetFramework="net45" />
  <package id="SystemWrapper.Wrappers" version="0.7.0.0" targetFramework="net45" />
</packages>
    class Program
    {
        static void Main(string[] args)
        {
            var wrapper = new RegistryWrap();
            IRegistryKey hklm = wrapper.LocalMachine;

            Console.WriteLine("KHLM: {0}", hklm.Name);
            Console.ReadKey();
        }
    }