search
AI OnAI Off
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.
Did you read this post? http://www.meadow.se/wordpress/unit-testing-an-episerver-contentarea/
Thanks @Johan! We had not read that. Will give it a go and update here.
Hi there,
We would like to unit test a validator that ensures a content area doesn't have two blocks inside it:
The problem we are facing is: how can we programatically add a second block to a content area, while inside the test project?
We have tried this approach: https://stackoverflow.com/questions/27993939/episerver-add-block-to-a-content-area-programmatically but that seems to work only in the main application (ContentReference.GlobalBlockFooter is null in the test project).
In case it helps, here is the data model.
And here is what we have tried:
However, it throws a null reference exception when we try to add the ContentAreaItem to the ContentArea (using model.HeroBlock.Items.Add). The exact error is: