EPiWiki.se  - EPiServer notes shared with others
 

Set up EPiServer for test driven development

[Edit]

Initialize EPiServer for TDD


Sample code how to set up a EPiServer implementation for test driven development.

Set up mock object for the class factory



IBaseLibraryFactory dbcl = new DefaultBaseLibraryFactory("1");
typeof (ClassFactory).GetField(
   "_instance",
   BindingFlags.Static |BindingFlags.NonPublic).SetValue(null, dbcl);

Set up ClassFactory


Set up ClassFactory with a mock object so you not ClassFactory not initialized exception.

ClassFactory.RegisterClass(typeof(IRuntimeCache), typeof(_myMockCache));

Assembly redirects


If you get errors like “Could not load file or assembly 'EPiServer.ApplicationModules' or one of its dependencies. The system cannot find the file specified.” You probably has missed to add all EPiServers assembly redirects (found in web.config) to the test projects configuration file (called <asseblyname>.dll.config)
Version author:
Mattias Lövström

EPiServer version

'EPiServer CMS 5'