本文整理汇总了C#中UserStore.FindAsync方法的典型用法代码示例。如果您正苦于以下问题:C# UserStore.FindAsync方法的具体用法?C# UserStore.FindAsync怎么用?C# UserStore.FindAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStore
的用法示例。
在下文中一共展示了UserStore.FindAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenHaveNoUser
public void WhenHaveNoUser()
{
var login = new UserLoginInfo("ProviderTest", "ProviderKey");
var store = new UserStore<IdentityUser>(_session);
var user = store.FindAsync(login).Result;
Assert.IsNull(user);
}
示例2: WhenAddLoginAsync
public void WhenAddLoginAsync()
{
var user = new IdentityUser("Lukz");
var login = new UserLoginInfo("ProviderTest02", "ProviderKey02");
var store = new UserStore<IdentityUser>(_session);
var result = store.AddLoginAsync(user, login);
var actual = _session.Query<IdentityUser>().FirstOrDefault(x => x.UserName == user.UserName);
var userStored = store.FindAsync(login).Result;
Assert.IsNull(result.Exception);
Assert.IsNotNull(actual);
Assert.AreEqual(user.UserName, actual.UserName);
Assert.AreEqual(user.UserName, userStored.UserName);
}
示例3: UserStoreMethodsThrowWhenDisposedTest
public void UserStoreMethodsThrowWhenDisposedTest()
{
var db = UnitTestHelper.CreateDefaultDb();
var store = new UserStore<IdentityUser>(db);
store.Dispose();
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)));
Assert.Throws<ObjectDisposedException>(
() => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindAsync(null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByIdAsync(null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByNameAsync(null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)));
Assert.Throws<ObjectDisposedException>(
() => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)));
Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)));
Assert.Throws<ObjectDisposedException>(
() => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)));
Assert.Throws<ObjectDisposedException>(
() => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)));
}
示例4: UserStorePublicNullCheckTest
public void UserStorePublicNullCheckTest()
{
var store = new UserStore<IdentityUser>();
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.CreateAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)),
"user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)),
"user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)),
"user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPasswordHashAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPasswordHashAsync(null, null)),
"user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetSecurityStampAsync(null)),
"user");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.SetSecurityStampAsync(null, null)), "user");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.AddClaimAsync(new IdentityUser("fake"), null)), "claim");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(new IdentityUser("fake"), null)), "claim");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.AddLoginAsync(new IdentityUser("fake"), null)), "login");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(new IdentityUser("fake"), null)), "login");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.FindAsync(null)), "login");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)),
"user");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetEmailAsync(null, null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPhoneNumberAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPhoneNumberAsync(null, null)),
"user");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)), "user");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)), "user");
ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetTwoFactorEnabledAsync(null)),
"user");
ExceptionHelper.ThrowsArgumentNull(
() => AsyncHelper.RunSync(() => store.SetTwoFactorEnabledAsync(null, true)), "user");
ExceptionHelper.ThrowsArgumentNullOrEmpty(
() => AsyncHelper.RunSync(() => store.AddToRoleAsync(new IdentityUser("fake"), null)), "roleName");
ExceptionHelper.ThrowsArgumentNullOrEmpty(
() => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(new IdentityUser("fake"), null)), "roleName");
ExceptionHelper.ThrowsArgumentNullOrEmpty(
() => AsyncHelper.RunSync(() => store.IsInRoleAsync(new IdentityUser("fake"), null)), "roleName");
}