May012008
Published by Guillermo at 6:30 PM under Development
For my current project, I am implementing WCF services that need to be able to authenticate the caller and since the caller is coming from the public network (but from known sources), using a custom username and password validation was determined to be the correct mechanism.
As part of this implementation, I needed to create a Custom Membership Provider and in doing so I of course had to have Unit Tests for it. Once the tests were written, I got a little surprise when I tried to run them as I got this exception:
System.ArgumentException: The membership provider name specified is invalid.
Needless to say this is an oversight on my part as it is clear that the providers need to be initialized. To do this as part of your unit tests project you will need to configure your providers as you would on your ASP.NET application, or as in this case your WCF service host.
1: <system.web>
2: <membership defaultProvider="MyCustomMembershipProvider">
3: <providers>
4: <remove name="AspNetSqlMembershipProvider"/>
5: <add name="MyCustomMembershipProvider"
6: type="GFST.ProjectName.Providers.MyCustomMembershipProvider, GFST.ProjectName.Providers" />
7: </providers>
8: </membership>
9: </system.web>
You can then execute unit tests against your Custom Membership provider.
Tags: troubleshooting, .net, unit testing, c#
E-mail | Permalink | Trackback | Post RSS 0 Responses
Response by on 1/7/2009 7:07:03 AM
Guillermo Salas You can also find me on: twitter friendfeed plurk tumblr pownce E-mail me
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.