title: Mocking a MembershipUser
body: <p>I'm currently developing an asp.net mvc 2 application which uses the default SqlMembershipProvider for authentication. I've implemented a controller method that reads the ProviderUserKey of the current user by calling <code>Membership.GetUser().ProviderUserKey</code>.
  Now I'm trying to write some test methods for this controller.</p>
  
  <p>To get rid of the dependancy on the static Membership class, I've created a thin wrapper and made my controller depend on the corresponding interface:</p>
  
  <pre><code>public interface IStaticMembershipService {
      MembershipUser GetUser();
  
      void UpdateUser(MembershipUser user);
  }
  </code></pre>
  
  <p>So far everything works, but in order to unit-test the controller, I still need to mock the <code>GetUser()</code> method of this interface and return a MembershipUser object that contains a ProviderUserKey property. What is the easiest way to mock such an object?</p>
  
  <p>I'm using moq as mocking framework.</p>