I know off the bat this a loaded question and there are probably tons of ideas, but I'm having a tough time online finding examples of the things that are typical to unit test in EPIServer.
I think a good start is if anyone had experience doing unit testing and TDD in a test environment, that will probably get us somewhere. I'm not familiar with CMS sort of unit testing with blocks and page types etc.. so I'm trying to get some guidance.
Thank you
A typical example would be things you're fetching using IContentLoader
.
Let's say you use the following code to fetch the main menu items:
var items = _contentLoader.GetChildren<PageData>(ContentReference.StartPage)
... // filtering
.ToList();
You obviously need to filter out container pages, restricted pages, unpublished pages, pages that have VisibleInMenu
set to False
, etc.
To unit test that, you would need to mock IServiceLocator
, IContentLoader
, ITemplateResolver
, IPublishedStateAssessor
, etc.
I haven't found any open source mocking/testing framework for Episerver other then https://github.com/DavidVujic/EPiServer-FakeMaker
Most companies that are unit testing Episerver solutions have developed their own frameworks, which are not publically available. David's FakeMaker is a good start.