Mocking User.Identity in ASP.NET MVC
Posted
by Trey Carroll
on Stack Overflow
See other posts from Stack Overflow
or by Trey Carroll
Published on 2010-06-12T02:42:17Z
Indexed on
2010/06/12
2:53 UTC
Read the original article
Hit count: 510
I need to create Unit Tests for an ASP.NET MVC 2.0 web site. The site uses Windows Authentication.
I've been reading up on the necessity to mock the HTTP context for code that deals with the HttpContext. I feel like I'm starting to get a handle on the DI pattern as well. (Give the class an attribute of type IRepository and then pass in a Repository object when you instantiate the controller.)
What I don't understand, however, is the proper way to Mock the Windows Principal object available through User.Identity. Is this part of the HttpContext?
Does any body have a link to an article that demonstrates this (or a recommendation for a book)?
Thanks,
Trey Carroll
© Stack Overflow or respective owner