Razor Generator HttpContextBase

Aug 14, 2012 at 9:49 PM

I am having issues with views that uses themvc WebGrid. My error message is: Value cannot be null.
Parameter name: httpContext.

I have tried to mock the HttpContextBase, but I am still receiving the same error.

unit test

var view = new StoreTablet.Views.Home.About();

HtmlDocument doc = view.RenderAsHtml();
HtmlNode node = doc.DocumentNode.Element("h2");

View

@{
ViewBag.Title = "About Us";
}


@{

var grid = new WebGrid(source: null,
defaultSort: "DriverName",
rowsPerPage: 20);
grid.SortDirection = SortDirection.Ascending;

}

Aug 16, 2012 at 5:11 PM

Is there any help with this issue?  I was hoping to demo Razor Generator today.

Coordinator
Aug 17, 2012 at 12:19 AM

I am assuming you were trying to demo the unit test. The problem in this case is that WebGrid uses HttpContext.Current and isn't designed to very testable (at least from outside).