public void SuccessfullAuthentication() { var userManager = new UserManager(); var services = new ServiceCollection() .AddLogging() .AddSingleton <IUserManager <int> >(userManager) .AddLoginAuthentication(b => b.AddPasswordAuthentication <UserManager, int>()) .BuildServiceProvider(true); using (var scope = services.CreateScope()) { var auth = scope.ServiceProvider.GetRequiredService <ILoginAuthentication>(); var pwd = PasswordLogin.GeneratePaswordHash("xasd"); userManager.Users.Add(new User { Id = 1, Email = "*****@*****.**", FamilyName = "a", GivenName = "b", Password = pwd.Hash, Salt = pwd.Salt }); CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; var p = auth.AuthenticateAsync("password", "[email protected]:xasd").Result; Assert.True(p.Identity.IsAuthenticated); Assert.Equal("1", p.FindFirst(ClaimTypes.Sid)?.Value); Assert.Equal("a", p.FindFirst(ClaimTypes.Surname)?.Value); Assert.Equal("b", p.FindFirst(ClaimTypes.GivenName)?.Value); Assert.Equal("b a", p.FindFirst(ClaimTypes.Name)?.Value); Assert.Equal("*****@*****.**", p.FindFirst(ClaimTypes.Email)?.Value); } }