Developer forum

Forum » Development » Using templates in unit tests

Using templates in unit tests


Reply
I'm trying to write a unit test for a part of my DynamicWeb application. In this test I want to use one of my DynamicWeb html templates.

When I try to access a template in the files/templates folder, however, I get the following error:

System.ArgumentNullException : Value cannot be null.
Parameter name: str
at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess accessAccessControlActions controlString[] pathListOrigBoolean checkForDuplicatesBoolean needFullPathBoolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess accessString path)
at System.Web.InternalSecurityPermissions.PathDiscovery(String path)
at System.Web.HttpRequest.MapPath(VirtualPath virtualPathVirtualPath baseVirtualDirBoolean allowCrossAppMapping)
at System.Web.HttpRequest.MapPath(VirtualPath virtualPath)
at System.Web.HttpServerUtility.MapPath(String path)
at Dynamicweb.Templatev2.Template.LoadTemplate(String Path)
at Dynamicweb.Templatev2.Template..ctor(String Path)
at (my class where Template template = new Template("MyTemplate.html"); is called

I'm guessing that this is because I am trying to access the template outside of a browser, resulting in the test not having the http context that the DynamicWeb template system expects.

Is there any way to create some sort of virtual http context or another way of utilising the DynamicWeb templates in unit tests?
 


Replies

 
Nicolai Høeg Pedersen

 

You must be logged in to post in the forum