I am working with XDocument within an MVC4 Web API application in Visual Studio 2010 and am unsure about the testing strategy.
Most of my unit tests make use of an in memory XDocument, which works well for controller, service, repository tests.
However, I have the XDocument.Load(filename)
and XDocument.Save(filename) scenarios, which I would like to test (either with unit or integration tests).
I have been looking at the following question\answer on SO here but I'm not sure how to proceed.
public class PathProvider
{
public virtual string GetPath()
{
return HttpContext.Current.Server.MapPath("App_Data/policies.xml")
}
}
PathProvider pathProvider = new PathProvider();
XDocument xdoc = XDocument.Load(pathProvider.GetPath());
So, I get that I can now mock calls to whatever calls XDocument.Load(pathProvider.GetPath()).
Should I then be trying to test that PathProvider works? If, so, How would I approach this?
Thanks
Davy