Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Did you read this post? http://www.meadow.se/wordpress/unit-testing-an-episerver-contentarea/
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: