Trying to utilise the PublishedContentRequest method in order to perform several unit tests. As this is separate project purely for unit testing there is no Umbraco context as such.
Just wondering if anyone else has had an issue with testing Umbraco this way. Really need to understand what uri it is expecting as well. For example is is "contact-us", "/contact-us" or "http://localhost/contact-us". Also would like to know how to setup the routingcontext correctly.
Got something like this at the moment:
private static void SetupControllerContext(UmbracoContext umbCtx, ControllerBase controller)
{
var contextBase = umbCtx.HttpContext;
var pcr = new PublishedContentRequest(new Uri("/contact-us"), umbCtx.RoutingContext);
var routeData = new RouteData();
var routeDefinition = new RouteDefinition
{
PublishedContentRequest = pcr
};
routeData.DataTokens.Add("umbraco-route-def", routeDefinition);
controller.ControllerContext = new ControllerContext(contextBase, routeData, controller);
}
Any pointers would be great.
Thanks