Quantcast
Channel: RazorGenerator Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 525

Commented Unassigned: Html.AntiForgeryToken and ArgumentException (Tests) [147]

$
0
0
If I try to unit test a view having Html.AntiForgeryToken() call inside I get an argument exception (An HttpContext is required to perform this operation. Check that this operation is being performed during a web request).

I tried to mock HttpContext (view.Context = Substitute.For<HttpContextBase>()) but is does not help.

(BTW: I am using MVC 5.0 and .NET 4.5)
Comments: Cool, I didn't realize the HttpContext.Current could be _set_. Ideally, we'd change the RZ testing helper to do something like this automatically.

Viewing all articles
Browse latest Browse all 525

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>