volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

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?

#81437
Feb 17, 2014 13:29

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

#81476
Feb 18, 2014 10:50

Here is my solution to this. Thanks Johan!

SiteDefinition.Current = new SiteDefinition()
{
StartPage = new PageReference(4)
};

#86311
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.