title: Having trouble getting started with Moq and Nunit
body: <p>Banging my head against a wall trying to get a really simple testing scenario working.
  I'm sure I'm missing something really simple!</p>
  
  <p>Whatever I do, I seem to get the following error from the NUnit gui when running a test against my DLL:
  <strong>System.TypeLoadException : Type 'Castle.Proxies.ITestProxy' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.</strong></p>
  
  <p>Now I've seen reference to this error in heaps of places when looking in Stack Overflow and elsewhere, but the solution I keep finding doesn't seem to help. And I'm not even using an internal interface at this stage! The solution I see around the place is too put the following line in AssemblyInfo.cs</p>
  
  <p><strong>[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]</strong></p>
  
  <p>I'm using:</p>
  
  <ul>
  <li>Visual Studio 2010 Professional</li>
  <li>c# 4.0</li>
  <li>Moq 4.10810.8 Beta (bin deployed)</li>
  <li>NUnit 2.5.5 (Installed in GAC)</li>
  </ul>
  
  <p>To recreate this error, all I need to do is:</p>
  
  <ol>
  <li>Create a new class library project</li>
  <li>Reference Moq and Unit (as above)</li>
  <li>Create an interface. I've called my interface ITest, made it public, and it has one method which is 'string TestMethod();'. Am doing this in the local project for simplicity.</li>
  <li>Create a class called 'Testing', decorated with [TextFixture] and a test method called 'TestMethod' decorated with [Test]</li>
  <li>Build the project, then run NUnit against the resulting dll in the Debug folder.</li>
  </ol>
  
  <p>Here's the contents of my test class</p>
  
  <pre><code>namespace MoqTest {
  [TestFixture]
  public class Testing {
      [Test]
      public void TestMethod() {
  
          var testMock = new Mock&lt;ITest&gt;();
          testMock.Setup(x =&gt; x.TestMethod()).Returns("String val");
          var xyz = testMock.Object;
  
          Assert.AreEqual(1, 1);
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>---- UPDATE ---</strong>
  After changing Moq version from 4.10810.8 to 4.0.10501.6 everything works fine!</p>