title: trying to test custom membership provider
body: <p>I'm trying to test my custom membership provider as it was described <a href="http://highoncoding.com/Articles/379_Unit_Testing_Membership_and_Role_Providers.aspx" rel="noreferrer">here</a></p>
  
  <p>On testing I have System.TypeLoadException:</p>
  
  <pre><code>Could not load type 'Domain.WebProviders' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral....,
  </code></pre>
  
  <p>Here is my code
  <strong>TestBase.cs</strong></p>
  
  <pre><code>public class TestBase
      {
          protected string _username;
          protected string _password;
          protected string _email;
          protected CustomMembershipProvider _provider;
          protected NameValueCollection _config;
          protected MembershipCreateStatus _status = new MembershipCreateStatus();
  
          [SetUp]
          public void initialize()
          {
              _username = "james";
              _password = "bondjamesbond";
              _email = "jamesbond@mi6.uk";
  
              // setup the membership provider
              _provider = new CustomMembershipProvider ();
  
              _config = new NameValueCollection();
              _config.Add("applicationName", "My App");
              _config.Add("name", "CustomMembershipProvider ");
              _config.Add("requiresQuestionAndAnswer", "false");
              _config.Add("connectionStringName", "ConnectionString");
              _provider.Initialize(_config["name"], _config);
  
              _status = new MembershipCreateStatus();
  
          }, ...
  </code></pre>
  
  <p><strong>MembershipTests.cs</strong></p>
  
  <pre><code>[TestFixture]
      class MembershipTests : TestBase
      {
          [Test]
          public void CanUserBeCreated()
          {
              using (ISession open session ....)
              {
                  using (ITransaction begin transaction ... )
                  {
                      _provider.CreateUser(_username, _password, _email, null, null, true, null, out _status);
                      tx.Commit();
                  }
                  Assert.AreEqual(MembershipCreateStatus.Success, _status);                
              }            
          }
  </code></pre>
  
  <p><strong>App.config</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="ConnectionString" connectionString="...." /&gt;
    &lt;/connectionStrings&gt;
    &lt;system.web&gt;
      &lt;!-- Membership provider --&gt;
      &lt;membership defaultProvider="CustomMembershipProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add name="CustomMembershipProvider" type="Domain.WebProviders.CustomMembershipProvider"
               enablePasswordRetrieval="false"
               enablePasswordReset="true"
               requiresQuestionAndAnswer="false"
               requiresUniqueEmail="true"
               maxInvalidPasswordAttempts="5"
               minRequiredPasswordLength="6"
               minRequiredNonalphanumericCharacters="0"
               passwordAttemptWindow="10"
               applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
      &lt;!-- Ends membership provider section--&gt;
      &lt;!-- Role provider --&gt;
      &lt;roleManager enabled="true" defaultProvider="MyRoleProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add applicationName="/"
              name="MyRoleProvider"
              type="Domain.WebProviders.MyRoleProvider" /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
      &lt;!-- Ends role provider --&gt;
    &lt;/system.web&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Updated App.config line with </p>
  
  <pre><code>&lt;add name="CustomMembershipProvider"
           type="Domain.WebProviders.CustomMembershipProvider, "Domain.WebProviders"
  </code></pre>
  
  <p>Now my reported exception is</p>
  
  <pre><code>System.IO.FileNotFoundException : Could not load file or assembly 'Domain.WebProviders' or one of its dependencies
  </code></pre>
  
  <p>Domain.WebProviders is referenced, pretty confused.</p>