lundi 28 septembre 2015

Mocking RenderingContext using Sitecore.FakeDB

I'm using Sitecore.FakeDB to write unittests for my Sitecore. I would like to mock the RenderingContext, to set the Rendering Parameters or Datasource of my current item.

However, when calling RenderingContext.Current, my unittest crashes with the following error:

Test method YourAssembly.YourClass.YourTest threw exception: 
System.InvalidOperationException: Attempt to retrieve context object of type 'Sitecore.Mvc.Presentation.RenderingContext' from empty stack.

Is mocking the RenderingContext supported by Sitecore.FakeDB?

If this is not supported, I'll abstract calls to RenderingContext away from my code using Marc Duiker's blog

Aucun commentaire:

Enregistrer un commentaire