Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Benjamin 6 posts 26 karma points
    Jul 24, 2013 @ 13:30
    Benjamin
    0

    Umbraco 6.12, unit testing controllers PublishedCachesResolver

    So im working with Umbraco 6.12 and having great difficulty been able to test a RenderMvcController.

    I have implemented IApplicationEventHandler in my Global.ascx and Ninject is working fine and as expected when running the application - all good.

    However, Unit Testing these controllers is a different matter. I found this, and have added the latest reply:

    http://issues.umbraco.org/issue/U4-1717

    I now have this lovely hack in my SetUp:

     Umbraco.Web.UmbracoContext.EnsureContext(new HttpContextWrapper(new HttpContext(new HttpRequest("", "http://www.myserver.com", ""), new HttpResponse(null))), ApplicationContext.Current);
    

    Which has got around the original "UmbracoContext" cannot be null, but is now throwing:

    Current has not been initialized on Umbraco.Web.PublishedCache.PublishedCachesResolver. You must initialize Current before trying to read it.
    

    The published caches resolver also seems to be hidden behind internal and protected stuff, which I cant use reflection to hack at as I cant init anything to pass into SetProperty reflection.

    Its really frustrating, im loving v6, and using uMapper is very nice. I can inject a repo, service, command or querry at will into the controllers and life is good - I just cant cover the controllers! Granted the controllers pass of straight to a repo, service command or querry but I would still like coverage over my controllers.

    Any help on this would be greatly appreciated.

    Thanks.

  • David Walton 1 post 21 karma points
    Jun 06, 2014 @ 19:26
    David Walton
    0

    I've run into this same issue & can only find others echoing the problem via google..

    Did you ever resolve this? If so, how?

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft