title: Register a Moq mock object as type for a Unity container
body: <p>Since my sut class has a constructor with a <code>IUnityContainer</code> as parameter I like to setup a new Unity container im my unit test and pass it to the sut.
  I like to use Moq here because I also have to veryfy for certain method calls. 
  What I've tried here is </p>
  
  <pre><code>public interface IFoo
      {
          void Bar();
      }
  
      class Program
      {
          static void Main(string[] args)
          {
              var fooMock = new Mock&lt;IFoo&gt;();
  
              fooMock.Setup(x =&gt; x.Bar()).Callback(() =&gt; Console.WriteLine("Hello"));
  
              IUnityContainer container = new UnityContainer();
              container.RegisterType(typeof (IFoo), fooMock.Object.GetType());
  
              var sut = container.Resolve&lt;IFoo&gt;();
              sut.Bar();
  
              Console.Read();
          }
      }
  </code></pre>
  
  <p>But this results in an <code>ResulutionFailedException</code>.
  Any ideas what I can do or what might be an alternative to this problem?</p>