How to make TDD a user membership provider and user membership user?

I need to create a user user and user application provider for ASP.NET mvc, and I am looking to use TDD. I created a User class that inherits from the MembershipUser class, but when I try to test it, I get an error message that I cannot understand. How to give it a valid supplier name? Do I just need to add it to web.config? But I do not even test the web application at the moment.

[crash] UserTests.SetUp.UserShouldHeesMembershipUserProperties TestCase 'UserTests.SetUp.UserShouldHembersMembershipUserProperties' failed: The specified membership provider name is invalid. Parameter Name: providerName System.ArgumentException Message. The specified membership provider name is invalid. Parameter Name: providerName Source: System.Web

+4
source share
2 answers

The configuration for adding unit test to the project configuration file will look something like this:

<connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="<connection string>" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <membership defaultProvider="provider"> <providers> <add name="provider" applicationName="MyApp" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" requiresQuestionAndAnswer="false" maxInvalidPasswordAttempts="3" passwordAttemptWindow="15"/> </providers> </membership> </system.web> 
+7
source

Yes, you need to configure it in your configuration file (maybe not in web.config for the test library, but app.config). You are still using the section inside this section to complete the configuration. After you do this, you can create an instance of your user and test it. At this point, you are likely to encounter new problems that I think you should post as separate issues.

+1
source

Source: https://habr.com/ru/post/1276769/


All Articles