<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Testing a Membership Provider</title>
	<atom:link href="http://elegantcode.com/2008/04/17/testing-a-membership-provider/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-a-membership-provider</link>
	<description></description>
	<lastBuildDate>Sun, 12 Feb 2012 18:54:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: Bryan Watts</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-20005</link>
		<dc:creator>Bryan Watts</dc:creator>
		<pubDate>Sun, 20 Apr 2008 16:29:22 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-20005</guid>
		<description>I didn&#039;t mean that you should register a provider per test - I meant that you should register all implementations that need to be tested. In your case, there is only 1 implementation, VirtualMembershipProvider, and that provider is the sole target of your test suite.

The same set of tests could be applied to another provider by registering it under a new name. You can target an entirely new implementation with the same tests using this technique. You end up with a line in the provider block per implementation, not per test.

A provider can be considered a pluggable implementation of an API. It is not meant to be stateful, i.e. requiring a &quot;fresh&quot; instance for each test. The only state in a provider is its configuration, which is scoped to all operations. If you need to test a different configuration, you now have a new implementation to register.and refer to.

What you are seeking to test is the particular implementation of an API represented by your provider. As such, you should be using the API to test, and ensure that API is hooked up to the correct implementation, not bypass it completely.

Consuming the provider and testing it are synonymous in a unit test.</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t mean that you should register a provider per test &#8211; I meant that you should register all implementations that need to be tested. In your case, there is only 1 implementation, VirtualMembershipProvider, and that provider is the sole target of your test suite.</p>
<p>The same set of tests could be applied to another provider by registering it under a new name. You can target an entirely new implementation with the same tests using this technique. You end up with a line in the provider block per implementation, not per test.</p>
<p>A provider can be considered a pluggable implementation of an API. It is not meant to be stateful, i.e. requiring a &#8220;fresh&#8221; instance for each test. The only state in a provider is its configuration, which is scoped to all operations. If you need to test a different configuration, you now have a new implementation to register.and refer to.</p>
<p>What you are seeking to test is the particular implementation of an API represented by your provider. As such, you should be using the API to test, and ensure that API is hooked up to the correct implementation, not bypass it completely.</p>
<p>Consuming the provider and testing it are synonymous in a unit test.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: trasa</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-20003</link>
		<dc:creator>trasa</dc:creator>
		<pubDate>Sun, 20 Apr 2008 14:56:28 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-20003</guid>
		<description>This doesn&#039;t allow me to meet the testing requirements of writing code like (apologies for this being all munged up):
[Test] public void CreateValidUser() { 
VirtualMembershipProvider provider = new VirtualMembershipProvider();
MembeshipUser testResult = provider.CreateUser(....);
}

Microsoft has had a hostile approach towards TDD and alternative approaches in general; for more evidence of that just google for anything &quot;ALT.Net&quot;.</description>
		<content:encoded><![CDATA[<p>This doesn&#8217;t allow me to meet the testing requirements of writing code like (apologies for this being all munged up):<br />
[Test] public void CreateValidUser() {<br />
VirtualMembershipProvider provider = new VirtualMembershipProvider();<br />
MembeshipUser testResult = provider.CreateUser(&#8230;.);<br />
}</p>
<p>Microsoft has had a hostile approach towards TDD and alternative approaches in general; for more evidence of that just google for anything &#8220;ALT.Net&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: trasa</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-20002</link>
		<dc:creator>trasa</dc:creator>
		<pubDate>Sun, 20 Apr 2008 14:05:14 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-20002</guid>
		<description>Adding a new line to the providers block for each test in the test app.config doesn&#039;t strike me as scalable at all - and to test individual parts of this provider, i need the ability to unload &amp; reload &quot;fresh&quot; copies of it.  so the immutable dependency is exactly the problem.

I think you&#039;re confusing consuming the provider with testing the provider itself.  I&#039;m not talking about writing unit tests for a web application that also uses membership provider, I&#039;m talking about writing unit tests for developing the provider itself.</description>
		<content:encoded><![CDATA[<p>Adding a new line to the providers block for each test in the test app.config doesn&#8217;t strike me as scalable at all &#8211; and to test individual parts of this provider, i need the ability to unload &#038; reload &#8220;fresh&#8221; copies of it.  so the immutable dependency is exactly the problem.</p>
<p>I think you&#8217;re confusing consuming the provider with testing the provider itself.  I&#8217;m not talking about writing unit tests for a web application that also uses membership provider, I&#8217;m talking about writing unit tests for developing the provider itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Watts</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-19986</link>
		<dc:creator>Bryan Watts</dc:creator>
		<pubDate>Sun, 20 Apr 2008 04:35:27 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-19986</guid>
		<description>Also, to be clear: your unit testing framework should support a way to load App.config which is not a manual build step, i.e. done automatically like in ASP.NET and Forms projects.

For example, a Google search of &quot;nunit app.config&quot; has this as the first result:

http://www.cornetdesign.com/2005/08/nunit-appconfig-files-its-all-about.html

You can tell your NUnit project the name of the configuration file; it will be loaded when the app is run, and reloaded with rebuilt DLLs.

_ReadOnly, in this case, is akin to a thin metal ruler:

http://blogs.msdn.com/ericlippert/archive/2003/11/03/53333.aspx</description>
		<content:encoded><![CDATA[<p>Also, to be clear: your unit testing framework should support a way to load App.config which is not a manual build step, i.e. done automatically like in ASP.NET and Forms projects.</p>
<p>For example, a Google search of &#8220;nunit app.config&#8221; has this as the first result:</p>
<p><a href="http://www.cornetdesign.com/2005/08/nunit-appconfig-files-its-all-about.html" rel="nofollow">http://www.cornetdesign.com/2005/08/nunit-appconfig-files-its-all-about.html</a></p>
<p>You can tell your NUnit project the name of the configuration file; it will be loaded when the app is run, and reloaded with rebuilt DLLs.</p>
<p>_ReadOnly, in this case, is akin to a thin metal ruler:</p>
<p><a href="http://blogs.msdn.com/ericlippert/archive/2003/11/03/53333.aspx" rel="nofollow">http://blogs.msdn.com/ericlippert/archive/2003/11/03/53333.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Watts</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-19985</link>
		<dc:creator>Bryan Watts</dc:creator>
		<pubDate>Sun, 20 Apr 2008 04:26:49 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-19985</guid>
		<description>App.config is the authority on the state of the framework running underneath your application. An app domain running a unit test is no different from a web app, Forms app, console app, or Windows service, from the perspective of the configuration system.

That is why there is a direct, immutable dependency on that system. It is *the* way to do what you seek to do. Any other approach is proprietary, introduces an unnecessary dichotomy, and most likely won&#039;t scale.

Your unit testing framework should have a way to load an App.config. If you need to test multiple providers of a system, you may register several and refer to each by name.</description>
		<content:encoded><![CDATA[<p>App.config is the authority on the state of the framework running underneath your application. An app domain running a unit test is no different from a web app, Forms app, console app, or Windows service, from the perspective of the configuration system.</p>
<p>That is why there is a direct, immutable dependency on that system. It is *the* way to do what you seek to do. Any other approach is proprietary, introduces an unnecessary dichotomy, and most likely won&#8217;t scale.</p>
<p>Your unit testing framework should have a way to load an App.config. If you need to test multiple providers of a system, you may register several and refer to each by name.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #76</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-19912</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #76</dc:creator>
		<pubDate>Fri, 18 Apr 2008 07:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-19912</guid>
		<description>[...] Testing a Membership Provider - Tony Rasa looks at creating an in memory Membership provider for test use. [...]</description>
		<content:encoded><![CDATA[<p>[...] Testing a Membership Provider &#8211; Tony Rasa looks at creating an in memory Membership provider for test use. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: trasa</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-19888</link>
		<dc:creator>trasa</dc:creator>
		<pubDate>Thu, 17 Apr 2008 19:25:30 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-19888</guid>
		<description>Also - just to be clear - the initialization procedures here are to set up unit tests *developing the provider itself* - and not meant for consumers of the provider.  They&#039;d use app.config and the standard initialization pipeline as normal.

That&#039;s why I can override the _ReadOnly field and not worry about what else that is going to break.  You wouldn&#039;t do that &quot;for real.&quot;</description>
		<content:encoded><![CDATA[<p>Also &#8211; just to be clear &#8211; the initialization procedures here are to set up unit tests *developing the provider itself* &#8211; and not meant for consumers of the provider.  They&#8217;d use app.config and the standard initialization pipeline as normal.</p>
<p>That&#8217;s why I can override the _ReadOnly field and not worry about what else that is going to break.  You wouldn&#8217;t do that &#8220;for real.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: trasa</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-19887</link>
		<dc:creator>trasa</dc:creator>
		<pubDate>Thu, 17 Apr 2008 19:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-19887</guid>
		<description>Ah, but I don&#039;t want to configure it from App.config, because I&#039;m driving this particular initialization from unit tests.  

I agree that a typical usage of a provider would be through the standard configuration mechanism.  But the provider doesn&#039;t give us a mechanism for following an alternative other than typical.

If there&#039;s a standard way for initializing membership providers in a unit test scenario, aside from some sort of hack involving multiple app.configs overloaded at run-time, I&#039;d love to hear it.</description>
		<content:encoded><![CDATA[<p>Ah, but I don&#8217;t want to configure it from App.config, because I&#8217;m driving this particular initialization from unit tests.  </p>
<p>I agree that a typical usage of a provider would be through the standard configuration mechanism.  But the provider doesn&#8217;t give us a mechanism for following an alternative other than typical.</p>
<p>If there&#8217;s a standard way for initializing membership providers in a unit test scenario, aside from some sort of hack involving multiple app.configs overloaded at run-time, I&#8217;d love to hear it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Watts</title>
		<link>http://elegantcode.com/2008/04/17/testing-a-membership-provider/comment-page-1/#comment-19883</link>
		<dc:creator>Bryan Watts</dc:creator>
		<pubDate>Thu, 17 Apr 2008 18:18:56 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/04/17/testing-a-membership-provider/#comment-19883</guid>
		<description>Membership.Providers is a run-time collection representing the configured providers for that system. It is made read-only so it can be initialized and then let loose in the wild.

The solution here is to configure your provider in App.config so it falls neatly into the initialization pipeline.

Conclusions:

  * Don&#039;t assume roadblocks are arbitrary. It is most likely there to prevent abuse in the first place.

 * Be sure to investigate the standard ways of accomplishing your goal before &quot;just getting it done&quot; - be sensitive to intent vs. mechanism.</description>
		<content:encoded><![CDATA[<p>Membership.Providers is a run-time collection representing the configured providers for that system. It is made read-only so it can be initialized and then let loose in the wild.</p>
<p>The solution here is to configure your provider in App.config so it falls neatly into the initialization pipeline.</p>
<p>Conclusions:</p>
<p>  * Don&#8217;t assume roadblocks are arbitrary. It is most likely there to prevent abuse in the first place.</p>
<p> * Be sure to investigate the standard ways of accomplishing your goal before &#8220;just getting it done&#8221; &#8211; be sensitive to intent vs. mechanism.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

