Unit Test class depending on startpage

Vote:
 

Ok so I am all new to unit testing and trying to get it to work with CMS 5 R2. I have searched all over but can't quite get the hang of it. In my test class I am making a new object of a class that is trying to access some properties on the startpage. To do it I am calling DataFactory.Instance.GetPage(PageReference.StartPage)

When I run the test I get a:

System.TypeInitializationException: The type initializer for 'EPiServer.DataFactory' threw an exception.

InnerException: {"The application relative virtual path '~/' is not allowed here."}

Is there any way I can access the start page either from my code or if I access the pagedata from the test code and then send the pagedata to my class?

 

#70896
May 03, 2013 10:09
Vote:
 

If I write:

PageReference pr = PageReference.StartPage;
PageData startPage = DataFactory.Instance.GetPage(pr)

I get:

"System.ApplicationException: First time you call Settings.Instance you must have a valid HttpContext."

I found it here but cannot see how it will help?
http://marekblotny.blogspot.se/2009/03/tdd-with-episerver.html

 

#70913
May 03, 2013 12:58
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.