예제 #1
0
        public async Task GetEmailConfirmedAsync_Should_Throw_InvalidOperationException_If_Email_Is_Not_Available()
        {
            const string userName = "******";
            const string userId   = "RavenUsers/Tugberk";

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

                    await ses.SaveChangesAsync();
                }

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    IUserEmailStore <RavenUser> userEmailStore = new RavenUserStore <RavenUser>(ses);
                    RavenUser ravenUser = await ses.LoadAsync <RavenUser>(userId);

                    await Assert.ThrowsAsync <InvalidOperationException>(async() =>
                    {
                        bool isConfirmed = await userEmailStore.GetEmailConfirmedAsync(ravenUser);
                    });
                }
            }
        }
예제 #2
0
        public async Task GetEmailConfirmedAsync_Should_Return_False_If_Email_Is_Not_Confirmed()
        {
            const string userName = "******";
            const string userId   = "RavenUsers/Tugberk";
            const string email    = "*****@*****.**";

            using (IDocumentStore store = CreateEmbeddableStore())
            {
                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    RavenUser      user      = new RavenUser(userName, email);
                    RavenUserEmail userEmail = new RavenUserEmail(email, user.Id);
                    await ses.StoreAsync(user);

                    await ses.StoreAsync(userEmail);

                    await ses.SaveChangesAsync();
                }

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    IUserEmailStore <RavenUser> userEmailStore = new RavenUserStore <RavenUser>(ses);
                    RavenUser ravenUser = await ses.LoadAsync <RavenUser>(userId);

                    bool isConfirmed = await userEmailStore.GetEmailConfirmedAsync(ravenUser);

                    Assert.False(isConfirmed);
                }
            }
        }
        public async Task GetEmailConfirmedAsync_Should_Throw_InvalidOperationException_If_Email_Is_Not_Available()
        {
            const string userName = "******";
            const string userId = "RavenUsers/Tugberk";

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

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    IUserEmailStore<RavenUser> userEmailStore = new RavenUserStore<RavenUser>(ses);
                    RavenUser ravenUser = await ses.LoadAsync<RavenUser>(userId);
                    
                    await Assert.ThrowsAsync<InvalidOperationException>(async () => 
                    {
                        bool isConfirmed = await userEmailStore.GetEmailConfirmedAsync(ravenUser);
                    });
                }
            }
        }
        public async Task GetEmailConfirmedAsync_Should_Return_False_If_Email_Is_Not_Confirmed()
        {
            const string userName = "******";
            const string userId = "RavenUsers/Tugberk";
            const string email = "*****@*****.**";

            using (IDocumentStore store = CreateEmbeddableStore())
            {
                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    RavenUser user = new RavenUser(userName, email);
                    RavenUserEmail userEmail = new RavenUserEmail(email, user.Id);
                    await ses.StoreAsync(user);
                    await ses.StoreAsync(userEmail);
                    await ses.SaveChangesAsync();
                }

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    IUserEmailStore<RavenUser> userEmailStore = new RavenUserStore<RavenUser>(ses);
                    RavenUser ravenUser = await ses.LoadAsync<RavenUser>(userId);
                    bool isConfirmed = await userEmailStore.GetEmailConfirmedAsync(ravenUser);

                    Assert.False(isConfirmed);
                }
            }
        }