title: Moq custom IIdentity
body: <p>I created a custom RoleProvider (standard webforms, no mvc) and I would like to test it. The provider itself integrates with a custom implementation of IIdentity (with some added properties).</p>
  
  <p>I have this at the moment: </p>
  
  <pre><code>var user = new Mock&lt;IPrincipal&gt;();
  var identity = new Mock&lt;CustomIdentity&gt;();
  
  user.Setup(ctx =&gt; ctx.Identity).Returns(identity.Object);
  identity.SetupGet(id =&gt; id.IsAuthenticated).Returns(true);
  identity.SetupGet(id =&gt; id.LoginName).Returns("test");
  
  // IsAuthenticated is the implementation of the IIdentity interface and LoginName 
  </code></pre>
  
  <p>However when I run this test in VS2008 then I get the following error message:</p>
  
  <p>Invalid setup on a non-overridable member: id => id.IsAuthenticated</p>
  
  <p>Why is this happening? And most important, what do I need to do to solve it?</p>
  
  <p>Grz, Kris.</p>