本文整理汇总了C#中UserStore.HasPasswordAsync方法的典型用法代码示例。如果您正苦于以下问题:C# UserStore.HasPasswordAsync方法的具体用法?C# UserStore.HasPasswordAsync怎么用?C# UserStore.HasPasswordAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStore
的用法示例。
在下文中一共展示了UserStore.HasPasswordAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasPasswordAsync_GivenAUserWithAPasswordHash_ReturnsTrue
public async void HasPasswordAsync_GivenAUserWithAPasswordHash_ReturnsTrue()
{
var applicationDatabaseConfiguration = new ApplicationDatabaseConfiguration();
var userStore = new UserStore<User>(applicationDatabaseConfiguration);
var user = new User
{
Email = "[email protected]",
IsEmailConfirmed = true,
PasswordHash = "PasswordHash",
PhoneNumber = "PhoneNumber",
IsPhoneNumberConfirmed = true,
IsTwoFactorEnabled = false,
LockoutEndDateUtc = null,
IsLockoutEnabled = true,
AccessFailedCount = 0,
UserName = "UserName",
IsAccountActive = true
};
await userStore.CreateAsync(user);
var hasPasswordHash = await userStore.HasPasswordAsync(user);
hasPasswordHash.Should().BeTrue();
}
示例2: When_User_Has_PasswordHash_HasPasswordHashAsync_Returns_True
public async void When_User_Has_PasswordHash_HasPasswordHashAsync_Returns_True()
{
var user = new IdentityUser("foo")
{
PasswordHash = "somehashedpassword"
};
var mockBucket = new Mock<IBucket>();
mockBucket.SetupGet(e => e.Name).Returns("default");
var store = new UserStore<IdentityUser>(new ThrowableBucket(mockBucket.Object));
Assert.IsTrue(await store.HasPasswordAsync(user));
}
示例3: When_User_Does_Not_Have_PasswordHash_HasPasswordHashAsync_Returns_False
public async void When_User_Does_Not_Have_PasswordHash_HasPasswordHashAsync_Returns_False()
{
var user = new IdentityUser("foo");
var mockBucket = new Mock<IBucket>();
mockBucket.SetupGet(e => e.Name).Returns("default");
var store = new UserStore<IdentityUser>(new ThrowableBucket(mockBucket.Object));
Assert.IsFalse(await store.HasPasswordAsync(user));
}
示例4: PasswordHash
public void PasswordHash()
{
using (UserStore<IdentityUser> store = new UserStore<IdentityUser>())
{
using (UserManager<IdentityUser> manager = new UserManager<IdentityUser>(store))
{
var user = User;
string passwordPlain = Guid.NewGuid().ToString("N");
string passwordHash = manager.PasswordHasher.HashPassword(passwordPlain);
var taskUserSet = store.SetPasswordHashAsync(user, passwordHash);
taskUserSet.Wait();
var taskHasHash = manager.HasPasswordAsync(user.Id);
taskHasHash.Wait();
Assert.IsTrue(taskHasHash.Result, "PasswordHash not set");
var taskUser = store.GetPasswordHashAsync(user);
taskUser.Wait();
Assert.AreEqual<string>(passwordHash, taskUser.Result, "PasswordHash not equal");
user.PasswordHash = passwordHash;
try
{
var task = store.GetPasswordHashAsync(null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
try
{
var task = store.HasPasswordAsync(null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
try
{
var task = store.SetPasswordHashAsync(null, passwordHash);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
try
{
var task = store.SetPasswordHashAsync(user, null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
}
}
}