I am trying to write a unit test for our log out method. Amoung other things it FormsAuthentication.SignOut(). However, it throws a System.NullReferenceException.
I've created myself a mock HttpContext (using Moq) but it is obviously missing something.
My mock context contains:
- A mocked
HttpRequestBaseonRequest - A mocked
HttpResponseBaseonResponse - With a
HttpCookieCollectiononRequest.Cookiesand another onResponse.Cookies - A mocked
IPrincipalonUser
I am aware I could go the wrapper route and inject an empty FormsAuth wrapper object in it's place, but I would really like to avoid the 3 additional files just to fix one line of code. That and I am still curious for an answer
So my question is "What is needed in the HttpContext to allow FormsAuthentication.SignOut() to execute."