Episerver Unit Testing

Writing well tested and reliable code should be the aim of every developer who works with Episerver.  This section covers some of the techniques to write unit tests within Episerver.

Dependency Injection In Episerver - ServiceLocator and Injected Explained

Dependency injection is a fairly standard computer science topic nowadays, but I still see a lot of confusion over how dependency injection works within Episerver. In today's guide, I'm going to cover the tools Episerver give us developers out the box and cover some of their pro's and con's. The ServiceLocator The ServiceLocator can be […]

How To Use Moq To Unit Test Episerver

Mocking the Content Repository One of the most useful unit testing tools available to you as a developer is Moq.  Moq is a lightweight mocking framework that will allow you to get a lot more test coverage in your projects.  If you have never used a mocking framework it might be a little daunting at […]

How To Unit Test Episerver Commerce

This might be a bit of a painful post for some people.  Episerver CMS has made amazing progress in the last few years towards creating a platform that is very easy to unit test.  Episerver commerce is making baby steps towards this goal as well, but it's very far behind. Before we start going into […]

Episerver 7 : Unit Testing Redirects In Controllers

Testing RedirectToAction If you want to unit test your controllers at some stage, you'll want to test your Action Results. In Epi-Server, it is very likely you may want to Redirect to another episerver page from an MVC controller, e.g. a redirect to any page, after login, or a redirect to the start page.  In […]

Episerver 7 : Unit Testing Using Fakes – Unit Testing Part 3

This is the third post in my unit testing series.  So far we have created a single Epi Dependencies class to manage ll or Epi Servers API in a single place.  In the second post, we created some basic unit tests using Moq to mock up these dependencies to make previously un-testable code testable.  In […]

Episerver 7 : Unit Testing Using Mocks - Unit Testing Part 2

This is the second part of my unit testing series.  In Unit Testing Part 1 I discussed simple ways that you can organise your project so all the Episerver API dependencies are hidden away in a single file to help improve your sites testability. As of yet we haven't gone into the details of why […]

EPiServer: Dependencies in Episerver Explained - Unit Testing Part 1

Trying to get 100% test coverage in your project is a noble goal.  With Episerver 7 onwards, unit testing is a lot more achievable.  In olden times, you may have a class that called the DataFactory to get some information from Episerver.  Doing this created a dependency to Episerver in your code.  When you came to […]