I'm not a fan of GetIdentity (and this seems to be a similar pattern) as it just introduces more mocks unnecessarily. Why not just have easy-to-use helpers that mock the whole HttpContextBase, since we often need other parts of that type. I definitely agree it needs to be as easy as "controller.Identity = ...", but I think there's a more generally-useful way of doing that.