title: Mocking Membership
body: <p>I'm writing a custom Profile provider, but I still intend to use the default AspNetSqlMembershipProvider as my Membership provider.  My GetAllProfiles() method in my Profile provider looks like this:</p>
  
  <pre><code>1    public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
  2    {
  3        // Get the profiles
  4        IQueryable&lt;Profile&gt; profiles = _profileRepository.GetAllProfiles();
  5    
  6        // Convert to a ProfileInfoCollection
  7        ProfileInfoCollection profileInfoCollection = new ProfileInfoCollection();
  8        foreach (Profile profile in profiles)
  9        {
  10           MembershipUser user = Membership.GetUser(profile.UserId);
  11   
  12           string username = user.UserName;
  13           bool isAnonymous = false;
  14           DateTime lastActivity = user.LastActivityDate;
  15           DateTime lastUpdated = profile.LastUpdated;
  16   
  17           ProfileInfo profileInfo = new ProfileInfo(username, isAnonymous, lastActivity, lastUpdated, 1);
  18   
  19           profileInfoCollection.Add(profileInfo);
  20       }
  21   
  22       // Set the total number of records.
  23       totalRecords = profiles.ToList().Count;
  24   
  25       return profileInfoCollection;
  26   }
  </code></pre>
  
  <p>How do I mock the Membership.GetUser() call so that I can write tests for this method?  Any suggestions or examples?  Thanks.  </p>