SaaS CMS has officially launched! Learn more now.

Unit test and ContentReference.StartPage


In EPiServer 7.0 and 7.1 I set the ContentReference.StartPage = new PageReference(4). In 7.5 this is not possible because ContentReference.StartPage is not writeable. (Invalid use of read-only object, call CreateWritableClone() to create a writable clone.)

The reason I want to set ContentReference.StartPage is that the property is used in some code to be tested. E.g. page.CompareToIgnoreWorkPageId(ContentReference.StartPage)

Does anyone have a solution to this?

Feb 17, 2014 13:29

in tests you can assign a value to EPiServer.Web.SiteDefinition.Current (ContentReference.StartPage is resolved from SiteDefinition.Current)

Feb 18, 2014 10:50

Here is my solution to this. Thanks Johan!

SiteDefinition.Current = new SiteDefinition()
StartPage = new PageReference(4)

May 19, 2014 10:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.