MVC Testing in Kentico 9

Marty Abrahams asked on June 1, 2016 09:34

I'm in the process of implementing integration tests on my controllers for an MVC Kentico 9 site.

I've got the basics working as per - https://docs.kentico.com/display/K9/Testing+MVC+controllers

I've faked my Repositories and Page Types and it works for the basics, however for one scenario my controller checks the RelatedDocuments on one of the faked content pages. As soon as the property is requested an exception is thrown.

CMS.DataEngine.DataClassNotFoundException : [DataClassInfoProvider.GetClassStructureInfoFromDB]: Class information for class 'CMS.Relationship' not found.

In order to test my controller properly I need to be able to fake the Related Documents for the tree node. I've also ran into a similar issue for .RelativeURL and .AbsoluteURL. The issue is that none of these properties have public setters. I'm hoping that there is a different way to populate these properties in a unit test.

I'm struggling to find any info on the subject, any help would really be appreciated.

   Please, sign in to be able to submit a new answer.