Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to mock a User in .NET Core

$
0
0

Hi,

I`m trying to mock User in ASP.NET Core as below however this can`t be done because controller.User can`t be set. How can I do this in .NET Core?

var identity = new GenericIdentity(username);
identity.AddClaim(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", username));
identity.AddClaim(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", userId));

var principle = new GenericPrinciple(identity, mull);

controller.User = principle;


Viewing all articles
Browse latest Browse all 9386

Trending Articles