Search code examples
asp.net-mvcstructuremaphttpcontext

StructureMap and items cached by HttpContext when unit testing


We are using StructureMap to cache a a class by InstanceScope.HttpContext. When unit testing a controller that depends on this type, null reference exceptions are thrown from within StructureMap that seem to indicate that it is trying to access the static current HttpContext (and not the MVC wrappers).

How could we fully configure HttpContext.Current (having decompliled structuremap it seems the error comes from here) to have a valid context that would work correctly with structuremap?


Solution

  • This is a known bug

    Just implement the fix and compile.