I have the following mocks:
var MockHttpContext = new Mock<HttpContextBase>();
var MockPrincipal = new Mock<IPrincipal>();
MockHttpContext.SetupGet(h => h.User).Returns(MockPrincipal.Object);
Error testing this line:
var user = (CustomPrincipal)httpContext.User;
This is mistake:
Unable to cast object of type 'IPrincipalProxy5c6adb1b163840e192c47295b3c6d696'
to type 'MyProject.Web.CustomPrincipal'.
My CustomPrincipal implements the IPrincipal interface. So can someone explain why I am getting this error and how can I solve it?
source
share