public void TestFindProfilesByUserName()
        {
            var membershipConfig = new NameValueCollection(_membershipConfig);
            var membershipProvider = new MongoMembershipProvider();
            membershipProvider.Initialize(DefaultMembershipName, membershipConfig);

            var profileConfig = new NameValueCollection(_profileConfig);
            var profileProvider = new MongoProfileProvider();
            profileProvider.Initialize(DefaultProfileName, profileConfig);

            SetUpTestProfiles(membershipProvider, profileProvider);

            int totalRecords = 0;
            var profiles = profileProvider.FindProfilesByUserName(ProfileAuthenticationOption.All, @"user2\d*", 0, 2, out totalRecords);

            Assert.AreEqual(10, totalRecords);
            Assert.AreEqual(2, profiles.Count);
            foreach (ProfileInfo p in profiles) {
                Assert.IsTrue(p.UserName.StartsWith("user2"));
                Assert.Greater(p.Size, 0);
            }
        }
        public void TestFindProfilesByUserNameThatAreAuthenticated()
        {
            var membershipConfig = new NameValueCollection(_membershipConfig);
            var membershipProvider = new MongoMembershipProvider();
            membershipProvider.Initialize(DefaultMembershipName, membershipConfig);

            var profileConfig = new NameValueCollection(_profileConfig);
            var profileProvider = new MongoProfileProvider();
            profileProvider.Initialize(DefaultProfileName, profileConfig);

            SetUpTestProfiles(membershipProvider, profileProvider);

            int totalRecords = 0;
            var profiles = profileProvider.FindProfilesByUserName(ProfileAuthenticationOption.Authenticated, @"user2\d*", 0, 2, out totalRecords);

            Assert.AreEqual(5, totalRecords);
            Assert.AreEqual(2, profiles.Count);
            foreach (ProfileInfo p in profiles) {
                Assert.IsTrue(p.UserName.StartsWith("user2"));

                // All even records are authenticated in this test.
                Assert.IsTrue(Convert.ToInt32(p.UserName.Substring(4)) % 2 == 0);

                Assert.IsFalse(p.IsAnonymous);
                Assert.Greater(p.Size, 0);
            }
        }
        public void TestDeleteProfilesUsingProfileInfoCollection()
        {
            var membershipConfig = new NameValueCollection(_membershipConfig);
            var membershipProvider = new MongoMembershipProvider();
            membershipProvider.Initialize(DefaultMembershipName, membershipConfig);

            var profileConfig = new NameValueCollection(_profileConfig);
            var profileProvider = new MongoProfileProvider();
            profileProvider.Initialize(DefaultProfileName, profileConfig);

            SetUpTestProfiles(membershipProvider, profileProvider);

            int numberOfUsersBefore, numberOfUsersAfter;
            membershipProvider.GetAllUsers(0, int.MaxValue, out numberOfUsersBefore);

            int totalRecords;
            var profiles = profileProvider.FindProfilesByUserName(ProfileAuthenticationOption.All, @"user3\d", 0, int.MaxValue, out totalRecords);
            var numberOfProfilesDeleted = profileProvider.DeleteProfiles(profiles);

            int numberOfProfilesRemaining;
            profileProvider.GetAllProfiles(ProfileAuthenticationOption.All, 0, int.MaxValue, out numberOfProfilesRemaining);

            membershipProvider.GetAllUsers(0, int.MaxValue, out numberOfUsersAfter);

            Assert.AreEqual(10, numberOfProfilesDeleted);
            Assert.AreEqual(70, numberOfProfilesRemaining);

            // No users should be removed by this process.
            Assert.AreEqual(numberOfUsersBefore, numberOfUsersAfter);
        }