Help features for test driving EPiServer CMS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Build status

Help features for test driving EPiServer CMS

There is also a NuGet package:

New! There is also a NuGet package for FakeMaker.Commerce:

What is FakeMaker?

FakeMaker takes care of mocking and a simplifies creating fake content, that you can use when testing your code.

Unit testing the EPiServer CMS got a whole lot easier with version 7. However, creating fake content to be used when setting up mocked repositories isn't that smooth, right?

When mocking of code is all you see on your screen, this little library may help. A bigger screen probably also would, but is probably more expensive. FakeMaker make it easier to write unit tests for mvc controllers and helpers that expect the episerver repositories to return content.

What about Commerce? Yes! FakeMaker now have support for Commerce. Check out the source code or install the FakeMaker.Commerce plugin from NuGet. The package currently suppport basic unit testing scenarios. What kind of features are missing? Create an issue here on GitHub and share your feedback, thoughts & ideas!

Quick Start


Just add the FakeMaker NuGet package (there is also a FakeMaker.Commerce package for Commerce projects) to your test project and you are ready. To avoid dependency version issues, make sure your test project has the references set up like the project under test. FakeMaker will use the existing references, otherwise install the version it is built with.

If you prefer using the source code, create a folder called "EPiFakeMaker" in your test project and drop the files FakeMaker.cs, FakePage.cs, Fake.cs and IFake.cs from the FakeMaker project in there. Also, drop the file FakeProduct.cs if you want the source code for Commerce.

FakeMaker relies on the Moq library and the EPiServer assemblies (currently version 9). The assembly references in the Visual Studio project file are added from both the official NuGet feed and the EPiServer feed if missing in the current project.


Have a look at the Example unit tests, containing some basic scenarios for unit testing with the FakeMaker and FakePage classes. If you want more scenarios, check out the FakeMaker.Tests and FakeMaker.Commerce.Tests library.

Roadmap? Here is the current roadmap.

EPiServer 8 support? This branch depends on EPiServer CMS version 9 references. Need version 8 support? Clone this repository and checkout the epi-8-support branch.

Create an instance of FakeMaker:

var fake = new FakeMaker();

Create the pages you need:

var page = FakePage.Create("MyPageName");

or a page of a specific page type:


Add it to the mocked repository (will be added to both IContentRepository and IContentLoader):


Get the mocked instance of the repository:

var repository = fake.ContentRepository;


var loader = fake.ContentLoader;

You can pass in the fake repository to the code you are about to test, by injecting it to the class (aka Dependency Injection) like this:

public void MyUnitTest()
  var controller = new MyController(fake.ContentRepository);

You can also use

var repository = ServiceLocator.Current.GetInstance<IContentRepository>();


var loader = ServiceLocator.Current.GetInstance<IContentLoader>();

in your controller as an alternative to Dependency Injection in your (controller) code under test.

Create fake Commerce products

var product = FakeProduct.Create<ProductContent>("My Fake Product");

and add it to the repository, just like with pages.


Please contact me if you have feedback or questions!