Beispiel #1
0
 public void CreateNewMembershipUserShouldCreateUserDocument()
 {
     using (var store = NewInMemoryStore())
     {
         var provider = new RavenDBMembershipProvider();
         provider.DocumentStore = store;
         MembershipCreateStatus status;
         var membershipUser = provider.CreateUser("martijn", "1234ABCD", "*****@*****.**", null, null, true, null, out status);
         Assert.Equal(MembershipCreateStatus.Success, status);
         Assert.NotNull(membershipUser);
         Assert.NotNull(membershipUser.ProviderUserKey);
         Assert.Equal("martijn", membershipUser.UserName);
     }
 }
Beispiel #2
0
        public void CreateNewMembershipUserShouldFailIfUsernameAlreadyUsed()
        {
            using (var store = NewInMemoryStore())
            {
                var provider = new RavenDBMembershipProvider();
                provider.DocumentStore = store;
                MembershipCreateStatus status;
                var membershipUser = provider.CreateUser("martijn", "1234ABCD", "*****@*****.**", null, null, true,
                                                         null, out status);

                Assert.Throws<MembershipCreateUserException>(delegate
                {
                    provider.CreateUser("martijn", "1234ABCD", "*****@*****.**", null, null, true, null, out status);
                });

                Assert.Equal(MembershipCreateStatus.DuplicateUserName, status);
            }
        }
Beispiel #3
0
        public void ChangePassword()
        {
            using (var store = NewInMemoryStore())
            {
                // Arrange
                var provider = new RavenDBMembershipProvider();
                provider.DocumentStore = store;
                MembershipCreateStatus status;
                var membershipUser = provider.CreateUser("martijn", "1234ABCD", "*****@*****.**", null, null, true, null, out status);

                // Act
                provider.ChangePassword("martijn", "1234ABCD", "DCBA4321");
                Thread.Sleep(500);

                // Assert
                Assert.True(provider.ValidateUser("martijn", "DCBA4321"));
            }
        }
Beispiel #4
0
        public void DeleteUser()
        {
            using (var store = NewInMemoryStore())
            {
                // Arrange
                var provider = new RavenDBMembershipProvider();
                provider.DocumentStore = store;
                MembershipCreateStatus status;
                var membershipUser = provider.CreateUser("martijn", "1234ABCD", "*****@*****.**", null, null, true, null, out status);

                // Act
                provider.DeleteUser("martijn", true);

                // Assert
                Thread.Sleep(500);
                using (var session = store.OpenSession())
                {
                    Assert.Equal(0, session.Query<User>().Count());
                }
            }
        }
Beispiel #5
0
        public void GetAllUsersShouldReturnAllUsers()
        {
            using (var store = NewInMemoryStore())
            {
                // Arrange
                CreateUsersInDocumentStore(store, 5);
                var provider = new RavenDBMembershipProvider();
                provider.DocumentStore = store;

                // Act
                Thread.Sleep(500);
                int totalRecords;
                var membershipUsers = provider.GetAllUsers(0, 10, out totalRecords);

                // Assert
                Assert.Equal(5, totalRecords);
                Assert.Equal(5, membershipUsers.Count);
            }
        }
Beispiel #6
0
        public void FindUsersWithPaging()
        {
            using (var store = NewInMemoryStore())
            {
                // Arrange
                CreateUsersInDocumentStore(store, 10);
                var provider = new RavenDBMembershipProvider();
                provider.DocumentStore = store;

                // Act
                Thread.Sleep(500);
                int totalRecords;
                var membershipUsers = provider.GetAllUsers(0, 5, out totalRecords);

                // Assert
                Assert.Equal(10, totalRecords); // All users should be returned
                Assert.Equal(5, membershipUsers.Count);
            }
        }
Beispiel #7
0
        public void FindUsersForDomain()
        {
            using (var store = NewInMemoryStore())
            {
                // Arrange
                CreateUsersInDocumentStore(store, 10);
                var provider = new RavenDBMembershipProvider();
                provider.DocumentStore = store;

                // Act
                Thread.Sleep(500);
                int totalRecords;
                var membershipUsers = provider.FindUsersByEmail("@foo.bar", 0, 2, out totalRecords);
                int totalRecordsForUnknownDomain;
                var membershipUsersForUnknownDomain = provider.FindUsersByEmail("@foo.baz", 0, 2, out totalRecordsForUnknownDomain);

                // Assert
                Assert.Equal(10, totalRecords); // All users should be returned
                Assert.Equal(2, membershipUsers.Count);
                Assert.Equal(0, totalRecordsForUnknownDomain);
                Assert.Equal(0, membershipUsersForUnknownDomain.Count);
            }
        }
Beispiel #8
0
        public void FindUsersByUsernamePart()
        {
            using (var store = NewInMemoryStore())
            {
                // Arrange
                CreateUsersInDocumentStore(store, 5);
                var provider = new RavenDBMembershipProvider();
                provider.DocumentStore = store;

                // Act
                Thread.Sleep(500);
                int totalRecords;
                var membershipUsers = provider.FindUsersByName("ser", 0, 10, out totalRecords); // Usernames are User1 .. Usern

                // Assert
                Assert.Equal(5, totalRecords); // All users should be returned
                Assert.Equal(5, membershipUsers.Count);
            }
        }