当前位置: 首页>>代码示例>>C#>>正文


C# UserStore.DeleteAsync方法代码示例

本文整理汇总了C#中UserStore.DeleteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# UserStore.DeleteAsync方法的具体用法?C# UserStore.DeleteAsync怎么用?C# UserStore.DeleteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserStore的用法示例。


在下文中一共展示了UserStore.DeleteAsync方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindByNameAsyncAsyncTest

        public async Task FindByNameAsyncAsyncTest()
        {
            var database = CreateDatabase();

            var store = new UserStore<ApplicationUser>(database);
            var user = new ApplicationUser() { UserName = "TestUser" };
            await store.CreateAsync(user);
            var userFromDb = await store.FindByNameAsync("testuser");
            Assert.IsTrue(userFromDb.Id.Length > 0);
            Assert.AreEqual(user.Id, userFromDb.Id);
            await store.DeleteAsync(user);
        }
开发者ID:peters,项目名称:Asp.Net-Identity-sample-app,代码行数:12,代码来源:StoreTests.cs

示例2: DeleteAsync_GivenAnExistingUser_UpdatesTheAccountToInActive

        public async void DeleteAsync_GivenAnExistingUser_UpdatesTheAccountToInActive()
        {
            var applicationDatabaseConfiguration = new ApplicationDatabaseConfiguration();
            var userStore = new UserStore<User>(applicationDatabaseConfiguration);

            var existingUser = await userStore.FindByNameAsync("UserName");
            existingUser.UserName = "HideMe";
            await userStore.UpdateAsync(existingUser);

            await userStore.DeleteAsync(existingUser);

            existingUser.IsAccountActive.Should().BeFalse();
        }
开发者ID:raypigott,项目名称:Identity,代码行数:13,代码来源:UserStoreTests.cs

示例3: Should_remove_user_role_record

        public void Should_remove_user_role_record() 
        {
            var user = new IdentityUser();
            user.Id = TestData.John_UserId;

            var target = new UserStore<IdentityUser>();

            var task = target.DeleteAsync(user);

            task.Wait();

            dynamic db = Database.Open();

            var userRoles = db.AspNetUserRole.FindAllByUserId(user.Id);
            Assert.That(userRoles, Is.Empty);
        }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:16,代码来源:When_user_is_deleted.cs

示例4: 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)));
 }
开发者ID:tomi85,项目名称:aspnetidentity,代码行数:30,代码来源:UserStoreTest.cs

示例5: CreateLoadDeleteUserTest

        public async Task CreateLoadDeleteUserTest()
        {
            var db = UnitTestHelper.CreateDefaultDb();
            var store = new UserStore<IdentityUser>(db);
            var user = new IdentityUser("Test");
            Assert.Null(await store.FindByIdAsync(user.Id));
            await store.CreateAsync(user);
            var loadUser = await store.FindByIdAsync(user.Id);
            Assert.NotNull(loadUser);

            Assert.Equal(user.Id, loadUser.Id);
            await store.DeleteAsync(loadUser);
            loadUser = await store.FindByIdAsync(user.Id);
            Assert.Null(loadUser);
        }
开发者ID:tomi85,项目名称:aspnetidentity,代码行数:15,代码来源:UserStoreTest.cs

示例6: DeleteUserTest

 public async Task DeleteUserTest()
 {
     var db = UnitTestHelper.CreateDefaultDb();
     var store = new UserStore<IdentityUser>(db);
     var mgmt = new IdentityUser("deletemgmttest");
     await store.CreateAsync(mgmt);
     Assert.NotNull(await store.FindByIdAsync(mgmt.Id));
     await store.DeleteAsync(mgmt);
     Assert.Null(await store.FindByIdAsync(mgmt.Id));
 }
开发者ID:tomi85,项目名称:aspnetidentity,代码行数:10,代码来源:UserStoreTest.cs

示例7: 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");
 }
开发者ID:tomi85,项目名称:aspnetidentity,代码行数:59,代码来源:UserStoreTest.cs

示例8: When_Not_Success_DeleteAsync_Throws_CouchbaseException

        public void When_Not_Success_DeleteAsync_Throws_CouchbaseException()
        {
            var mockBucket = new Mock<IBucket>();
            mockBucket.SetupGet(e => e.Name).Returns("default");

            var mockResult = new Mock<IOperationResult<IdentityUser>>();
            mockResult.SetupGet(x => x.Success).Returns(false);
            mockBucket.Setup(x => x.RemoveAsync(It.IsAny<string>()))
                .ReturnsAsync(mockResult.Object);

            var mockResult2 = new Mock<IOperationResult<string>>();
            mockResult2.SetupGet(x => x.Success).Returns(false);
            mockBucket.Setup(x => x.RemoveAsync(It.IsAny<string>()))
              .ReturnsAsync(mockResult2.Object);

            var mockResult3 = new Mock<IOperationResult<string>>();
            mockResult3.SetupGet(x => x.Success).Returns(false);
            mockBucket.Setup(x => x.RemoveAsync(It.IsAny<string>()))
              .ReturnsAsync(mockResult3.Object);

            var user = new IdentityUser("foo")
            {
                Email = "[email protected]"
            };

            var store = new UserStore<IdentityUser>(new ThrowableBucket(mockBucket.Object));
            Assert.Throws<CouchbaseException>(async () => await store.DeleteAsync(user));
        }
开发者ID:RoyGoode,项目名称:couchbase-aspnet-identity,代码行数:28,代码来源:UserStoreTests.cs

示例9: UpdateAsyncAsyncTest

        public async Task UpdateAsyncAsyncTest()
        {
            var database = CreateDatabase();

            var store = new UserStore<ApplicationUser>(database);
            var user = new ApplicationUser() { UserName = "TestUser" };
            await store.CreateAsync(user);
            var id = user.Id;
            Assert.IsTrue(id.Length > 0);

            user.PasswordHash = "testhash";
            user.UserName = "modified user name";

            await store.UpdateAsync(user);
            Assert.AreEqual(id, user.Id);

            var updatedUser = await store.FindByIdAsync(id);
            Assert.AreEqual("testhash", updatedUser.PasswordHash);
            Assert.AreEqual("modified user name", updatedUser.UserName);
            await store.DeleteAsync(user);
        }
开发者ID:peters,项目名称:Asp.Net-Identity-sample-app,代码行数:21,代码来源:StoreTests.cs

示例10: GivenHaveRoles_WhenDeleteUser_ThenDeletingCausesNoCascade

        public void GivenHaveRoles_WhenDeleteUser_ThenDeletingCausesNoCascade()
        {
            var user = new IdentityUser("Lukz 04");
            var role = new IdentityRole("ADM");
            var store = new UserStore<IdentityUser>(_session);
            var roleStore = new RoleStore<IdentityRole>(_session);

            roleStore.CreateAsync(role);
            store.CreateAsync(user);
            store.AddToRoleAsync(user, "ADM");

            Assert.IsTrue(_session.Query<IdentityRole>().Any(x => x.Name == "ADM"));
            Assert.IsTrue(_session.Query<IdentityUser>().Any(x => x.UserName == "Lukz 04"));

            var result = store.DeleteAsync(user);

            Assert.IsNull(result.Exception);
            Assert.IsFalse(this._session.Query<IdentityUser>().Any(x => x.UserName == "Lukz 04"));
            Assert.IsTrue(this._session.Query<IdentityRole>().Any(x => x.Name == "ADM"));
        }
开发者ID:dags20,项目名称:NHibernate.AspNet.Identity.MultiTenant,代码行数:20,代码来源:UserStoreTest.cs


注:本文中的UserStore.DeleteAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。