title: exception when mocking a unity container
body: <p>I am trying to mock a unity container - I using Moq and Getting this errror</p>
  
  <pre><code>System.ArgumentException: Invalid setup on a non-overridable member:
  c =&gt; c.Resolve&lt;ILogisticsAdapter&gt;(new [] {})
  </code></pre>
  
  <p>Here is the code from the setup portion of my test. </p>
  
  <pre><code> var mockContainer = new Mock&lt;IUnityContainer&gt;();
        mockContainer.Setup(c =&gt; c.Resolve&lt;ILogisticsAdapter&gt;()).Returns(logicsticsAdapter);
        IUnityContainer container = mockContainer.Object;
  </code></pre>
  
  <p>What am I missing? I am no master at mocks in general or unit testing but from what I can tell this should work... </p>
  
  <p>Just in case it is important I am using VS2010 and MS Test... </p>
  
  <p>Thanks</p>
  
  <p>Here is the whole test fixture -you can see I have changed it to use a real unity container however ideally I don't want to create a real unity container - it isn't what I am testing. You can however see the code I commented out... </p>
  
  <pre><code> [TestMethod]
  public void WhenContructed_AdapterGetsSet()
  {
    //Prepare
    ILogisticsAdapter logicsticsAdapter = new Mock&lt;ILogisticsAdapter&gt;().Object;
    var mockEventAggregator = new Mock&lt;IEventAggregator&gt;();
    mockEventAggregator.Setup(x =&gt; x.GetEvent&lt;SetHelpMessageEvent&gt;()).Returns(new SetHelpMessageEvent());
    IEventAggregator eventAggregator = mockEventAggregator.Object;
    IRegionManager regionManager = new Mock&lt;IRegionManager&gt;().Object;
  
    //var mockContainer = new Mock&lt;IUnityContainer&gt;();
    //mockContainer.Setup(c =&gt; c.Resolve&lt;ILogisticsAdapter&gt;(null)).Returns(logicsticsAdapter);
    //IUnityContainer container = mockContainer.Object;
    IUnityContainer container = new UnityContainer();
    container.RegisterInstance&lt;ILogisticsAdapter&gt;(logicsticsAdapter);
    container.RegisterInstance&lt;IRegionManager&gt;(regionManager);
    container.RegisterInstance&lt;IEventAggregator&gt;(eventAggregator);
  
    //Act
    var warehouseOrdersViewModel = new WarehouseOrdersViewModel_Accessor(container);
    Assert.IsNotNull(warehouseOrdersViewModel.logisticsAdapter);
  
  }
  </code></pre>
  
  <p>Thanks!</p>