private static async Task AddInitializeUserDataAsync(this IDbContext dbContext, ISignInManager signInManager) { var usersTable = dbContext.Set <User>(); if (!(await usersTable.AnyAsync())) { var user1 = new User { FirstName = "fn 1", LastName = "ln 1", UserName = "******", Email = "*****@*****.**", Active = true, CreatedOnUtc = DateTime.UtcNow }; signInManager.CreatePassword(user1, "123"); var user2 = new User { FirstName = "fn 2", LastName = "ln 2", UserName = "******", Email = "*****@*****.**", Active = true, CreatedOnUtc = DateTime.UtcNow }; signInManager.CreatePassword(user2, "123a"); usersTable.AddRange(user1, user2); dbContext.SaveChanges(); } }
public void create_user_hashed_password_and_salt() { var user = new User { FirstName = "fn test", LastName = "ln test", UserName = "******", Email = "*****@*****.**", Active = true, CreatedOnUtc = DateTime.UtcNow }; _signInManager.CreatePassword(user, "123"); Assert.NotEmpty(user.HashedPassword); Assert.NotEmpty(user.Salt); }