ASP.NET MVC unit testing custom AuthorizeAttribute
问题 I'm working on an ASP.NET MVC 4 project (.NET framework 4) and I was wondering how to properly unit test a custom AuthorizeAttribute (I use NUnit and Moq). I overrode 2 methods: AuthorizeCore(HttpContextBase httpContext) and HandleUnauthorizedRequest(AuthorizationContext filterContext) . As you can see, these methods expect an HttpContextBase and AuthorizationContext respectively, but I don't know how to Mock these. This is as far as I got: [Test] public void HandleUnauthorizedRequest