本文整理汇总了C#中UserStore.SetEmailAsync方法的典型用法代码示例。如果您正苦于以下问题:C# UserStore.SetEmailAsync方法的具体用法?C# UserStore.SetEmailAsync怎么用?C# UserStore.SetEmailAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStore
的用法示例。
在下文中一共展示了UserStore.SetEmailAsync方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetEmailAsync_GivenAUserAndEmail_SetTheUsersEmail
public async void SetEmailAsync_GivenAUserAndEmail_SetTheUsersEmail()
{
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);
await userStore.SetEmailAsync(user, "[email protected]");
var emailAddress = await userStore.GetEmailAsync(user);
emailAddress.Should().Be("[email protected]");
}
示例2: Should_set_email
public void Should_set_email()
{
var target = new UserStore<IdentityUser>();
var task = target.SetEmailAsync(TestData.GetTestUserJohn(), "[email protected]");
task.Wait();
var db = Database.Open();
IdentityUser userDetails = db.AspNetUsers.FindAllById(TestData.John_UserId).FirstOrDefault();
Assert.That(userDetails.Email, Is.EqualTo("[email protected]"));
}
示例3: 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");
}
示例4: When_User_Does_Not_Exist_SetEmailAsync_Fails
public async void When_User_Does_Not_Exist_SetEmailAsync_Fails()
{
var user = new IdentityUser("foo");
var expectedEmail = "[email protected]";
var mockResult = new Mock<IOperationResult<IdentityUser>>();
mockResult.SetupGet(x => x.Success).Returns(false);
mockResult.SetupGet(x => x.Status).Returns(ResponseStatus.KeyNotFound);
var mockBucket = new Mock<IBucket>();
mockBucket.SetupGet(e => e.Name).Returns("default");
mockBucket.Setup(x => x.ReplaceAsync(It.IsAny<string>(), It.IsAny<IdentityUser>()))
.ReturnsAsync(mockResult.Object);
var store = new UserStore<IdentityUser>(new ThrowableBucket(mockBucket.Object));
await store.SetEmailAsync(user, expectedEmail);
Assert.Throws<CouchbaseException>(async () => await store.UpdateAsync(user));
}
示例5: When_User_Exists_SetEmailAsync_Succeeds
public void When_User_Exists_SetEmailAsync_Succeeds()
{
var user = new IdentityUser("foo");
var expectedEmail = "[email protected]";
var mockResult = new Mock<IOperationResult<IdentityUser>>();
mockResult.SetupGet(x => x.Success).Returns(true);
mockResult.SetupGet(x => x.Status).Returns(ResponseStatus.Success);
var mockBucket = new Mock<IBucket>();
mockBucket.SetupGet(e => e.Name).Returns("default");
mockBucket.Setup(x => x.ReplaceAsync(It.IsAny<string>(), It.IsAny<IdentityUser>()))
.ReturnsAsync(mockResult.Object);
var store = new UserStore<IdentityUser>(new ThrowableBucket(mockBucket.Object));
Assert.DoesNotThrow(async () => await store.SetEmailAsync(user, expectedEmail));
Assert.AreEqual(expectedEmail, user.Email);
}
示例6: Email
public void Email()
{
using (UserStore<IdentityUser> store = new UserStore<IdentityUser>())
{
using (UserManager<IdentityUser> manager = new UserManager<IdentityUser>(store))
{
var user = User;
string strNewEmail = string.Format("{0}@gmail.com", Guid.NewGuid().ToString("N"));
SetValidateEmail(manager, store, user, strNewEmail);
try
{
var task = store.GetEmailAsync(null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
try
{
var task = store.SetEmailAsync(null, strNewEmail);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
try
{
var task = store.SetEmailAsync(user, null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
}
}
}
示例7: Should_throw_ArgumentNullException_if_user_is_null
public void Should_throw_ArgumentNullException_if_user_is_null()
{
var target = new UserStore<IdentityUser>();
Assert.Throws<ArgumentNullException>(() => target.SetEmailAsync(null, ""));
}
示例8: Should_throw_ObjectDisposedException_calling_FindByBName_and_disposed
public void Should_throw_ObjectDisposedException_calling_FindByBName_and_disposed()
{
var target = new UserStore<IdentityUser>();
target.Dispose();
Assert.Throws<ObjectDisposedException>(() => target.SetEmailAsync(new IdentityUser(), ""));
}