diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs
index b48d680918..7d14797fd1 100644
--- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs
+++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs
@@ -37,7 +37,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
/// A valid route is either a simple path eg /foo/bar/nil or a root node id and a path, eg 123/foo/bar/nil.
/// If is null then the settings value is used.
///
- public IPublishedContent GetByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null)
+ public virtual IPublishedContent GetByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null)
{
if (route == null) throw new ArgumentNullException("route");
@@ -79,7 +79,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
/// The context.
/// The content unique identifier.
/// The route.
- public string GetRouteById(UmbracoContext umbracoContext, int contentId)
+ public virtual string GetRouteById(UmbracoContext umbracoContext, int contentId)
{
// try to get from cache if not previewing
var route = umbracoContext.InPreviewMode
@@ -176,6 +176,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
if (node.Parent == null)
{
var rootNode = umbracoContext.ContentCache.GetByRoute("/", true);
+ if (rootNode == null)
+ throw new Exception("Failed to get node at /.");
if (rootNode.Id == node.Id) // remove only if we're the default node
pathParts.RemoveAt(pathParts.Count - 1);
}
@@ -270,12 +272,12 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
return ConvertToDocument(GetXml(umbracoContext).GetElementById(nodeId.ToString()));
}
- public IEnumerable GetAtRoot(UmbracoContext umbracoContext)
+ public virtual IEnumerable GetAtRoot(UmbracoContext umbracoContext)
{
return (from XmlNode x in GetXml(umbracoContext).SelectNodes(XPathStrings.RootDocuments) select ConvertToDocument(x)).ToList();
}
- public IPublishedContent GetSingleByXPath(UmbracoContext umbracoContext, string xpath, params XPathVariable[] vars)
+ public virtual IPublishedContent GetSingleByXPath(UmbracoContext umbracoContext, string xpath, params XPathVariable[] vars)
{
if (xpath == null) throw new ArgumentNullException("xpath");
if (string.IsNullOrWhiteSpace(xpath)) return null;
@@ -287,7 +289,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
return ConvertToDocument(node);
}
- public IEnumerable GetByXPath(UmbracoContext umbracoContext, string xpath, params XPathVariable[] vars)
+ public virtual IEnumerable GetByXPath(UmbracoContext umbracoContext, string xpath, params XPathVariable[] vars)
{
if (xpath == null) throw new ArgumentNullException("xpath");
if (string.IsNullOrWhiteSpace(xpath)) return Enumerable.Empty();
@@ -299,7 +301,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
return ConvertToDocuments(nodes);
}
- public bool HasContent()
+ public virtual bool HasContent()
{
var xml = GetXml();
if (xml == null)