예제 #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);
     }
 }
예제 #2
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"));
            }
        }
예제 #3
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());
                }
            }
        }
예제 #4
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);
            }
        }