This project is read-only.

Basic functionality

The assembly comes with adapters for Membership, FormsAuthentication and ConfigurationManager. You can use them as the default adapters.

In your ASP.NET or MVC project you can then simply do a replace in the code to make it (mostly) testable.

  • ConfigurationManager.AppSettings becomes ConfigurationManagerFactory.Current.AppSettings
  • FormsAuthentication. becomes FormsAuthenticationFactory.Current.
  • Membership. becomes MembershipFactory.Current.
  • HttpContext.Current. becomes HttpContextFactory.Current.

Using with an IOC container (usually not while testing)

In the method where you configure your container you can specify a creation function to the factory.

MembershipFactory.SetCreationFunction(() => 
    return ServiceLocator.Current.GetInstance<IMembership>(); 


FormsAuthenticationFactory.SetCreationFunction(() => 

Setting the context manually during testing

If you hand-create your own mocks, you can set the factory to use your mocks like so:

MembershipFactory.SetContext(new MockMembershipAdapter());


Last edited May 27, 2013 at 11:58 PM by rickrat, version 7


No comments yet.