private static User CreateUser() { using (var ctx = _factory.CreateDbContext(new string[0])) { Console.WriteLine("Username (must be an Email): "); string username; do { username = Console.ReadLine(); } while (!username.IsValidEmail()); Console.WriteLine("Password"); var password = Console.ReadLine(); var user = JwtAuthenticationService.CreateNewUser(username); JwtAuthenticationService.UpdatePassword(user, password); ctx.Users.Add(user); ctx.SaveChanges(); var person = new RealPerson { Firstname = "Mr.", Lastname = "Administrator", UserId = user.Id }; ctx.RealPeople.Add(person); ctx.SaveChanges(); return(user); } }
public void CreateNewUser() { var username = "******"; var usr = JwtAuthenticationService.CreateNewUser(username); Assert.Equal(username, usr.EMail); Assert.True(string.IsNullOrWhiteSpace(usr.Password)); Assert.True(string.IsNullOrWhiteSpace(usr.ResetHash)); Assert.NotNull(usr.Claims.FirstOrDefault(x => x.Type == UsernameClaim.USERNAME_CLAIM_TYPE && x.Value == username)); }