Example #1
0
        public async Task GetTwoFactorEnabledAsync_Should_Get_User_IsTwoFactorEnabled_Value()
        {
            using (IDocumentStore store = CreateEmbeddableStore())
            {
                const string userName = "******";
                const string userId   = "RavenUsers/Tugberk";

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    RavenUser user = new RavenUser(userName);
                    user.EnableTwoFactorAuthentication();
                    await ses.StoreAsync(user);

                    await ses.SaveChangesAsync();
                }

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    // Act
                    ses.Advanced.UseOptimisticConcurrency = true;
                    RavenUser user = await ses.LoadAsync <RavenUser>(userId);

                    IUserTwoFactorStore <RavenUser, string> userTwoFactorStore = new RavenUserStore <RavenUser>(ses);
                    bool isTwoFactorEnabled = await userTwoFactorStore.GetTwoFactorEnabledAsync(user);

                    // Assert
                    Assert.True(isTwoFactorEnabled);
                }
            }
        }
        public async Task GetTwoFactorEnabledAsync_Should_Get_User_IsTwoFactorEnabled_Value()
        {
            using (IDocumentStore store = CreateEmbeddableStore())
            {
                const string userName = "******";
                const string userId = "RavenUsers/Tugberk";

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    RavenUser user = new RavenUser(userName);
                    user.EnableTwoFactorAuthentication();
                    await ses.StoreAsync(user);
                    await ses.SaveChangesAsync();
                }

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    // Act
                    ses.Advanced.UseOptimisticConcurrency = true;
                    RavenUser user = await ses.LoadAsync<RavenUser>(userId);
                    IUserTwoFactorStore<RavenUser, string> userTwoFactorStore = new RavenUserStore<RavenUser>(ses);
                    bool isTwoFactorEnabled = await userTwoFactorStore.GetTwoFactorEnabledAsync(user);

                    // Assert
                    Assert.True(isTwoFactorEnabled);
                }
            }
        }