Unit testcases for Razor view (pre-compiled) throws an exception for included Bundle using Styles.Render or Scripts.Render.

Feb 19, 2015 at 8:09 PM
Unit testcase is expecting HttpContext and throws below exception.

System.ArgumentNullException crossed a native/managed boundary
HResult=-2147467261
Message=Value cannot be null.
Parameter name: httpContext
Source=System.Web
ParamName=httpContext
StackTrace:
   at System.Web.HttpContextWrapper..ctor(HttpContext httpContext)
   at System.Web.Optimization.Scripts.get_Context()
   at System.Web.Optimization.Scripts.get_Manager()
   at System.Web.Optimization.Scripts.RenderFormat(String tagFormat, String[] paths)
   at System.Web.Optimization.Scripts.Render(String[] paths)
   at ASP._Views_Home_Index_cshtml.Execute() in d:\R&D Samples\MvcApplicationRazorGeneratorSeparateLibrary-master\MvcApplicationRazorGeneratorSeparateLibrary-master\LibraryViewProject\Views\Home\Index.cshtml:line 10
   at RazorGenerator.Testing.WebViewPageExtensions.Render[TModel](WebViewPage`1 view, HttpContextBase httpContext, TModel model)
   at RazorGenerator.Testing.WebViewPageExtensions.Render[TModel](WebViewPage`1 view, TModel model)
   at LibraryViewProjectTests.ViewTests.TestIndexView() in d:\R&D Samples\MvcApplicationRazorGeneratorSeparateLibrary-master\MvcApplicationRazorGeneratorSeparateLibrary-master\LibraryViewProjectTests\ViewTests.cs:line 28
InnerException:

How can I mock web.optimization or handle render method?
Coordinator
Feb 19, 2015 at 8:29 PM
The unit test support is still in a somewhat experimental state. You may need to debug into it and see what's going on.