Testing Membership provider without ASP.NET

拟墨画扇 提交于 2019-12-07 04:20:43

问题


I have a ASP.NET MVC site using Membership Provider. I have trouble testing some functionalities including register a new user.

The ASP.NET website doesn't have a way to delete/remove a registered user, so in my testing project (WatiN with NUnit), I am trying to delete a testing user account by calling Membership.DeleteUser(). Then I realize I cannot use this since I cannot configure the membership provider with web.config in my NUnit project (in visual studio).

How do I configure the membership provider without using ASP.NET?


回答1:


You configure it in your app.config for your NUnit project. Check out this blog post. It provides an example (or close) to what you want to do.

Add the following to your app.config (from the first blog above):

 <system.web>

    <membership defaultProvider="MeanWormMembershipProvider">
      <providers>
        <remove name="AspNetSqlMembershipProvider"/>

          <add applicationName="MeanWorm" requiresQuestionAndAnswer="false"
            requiresUniqueEmail="true" minRequiredNonalphanumericCharacters="0"
            enablePasswordReset="true" passwordFormat="Hashed" connectionStringName="MeanWormConnectionString"
            name="MeanWormMembershipProvider" type="MeanWorm.Domain.Providers.MeanWormMembershipProvider,MeanWorm.Domain"/>

      </providers>
    </membership>
  </system.web>



回答2:


Have you looked into the Client Application Services? I'm not sure if that is what you want, but it is worth looking into.



来源:https://stackoverflow.com/questions/1081146/testing-membership-provider-without-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!