Hello,
I have the following mocks:
var MockHttpContext = new Mock<HttpContextBase>();
var MockPrincipal = new Mock<IPrincipal>();
MockHttpContext.SetupGet(h => h.User).Returns(MockPrincipal.Object);
The error occurs when testing this line:
var user = (CustomPrincipal)httpContext.User;
This is the error:
Unable to cast object of type 'IPrincipalProxy5c6adb1b163840e192c47295b3c6d696'
to type 'MyProject.Web.CustomPrincipal'.
My CustomPrincipal implements the IPrincipal interface. So can anybody explain why I am getting that error and how I can solve it?
Thanks in advance,
Pickels