public static void ClassCleanup()
        {
            //We will remove our sample users
            var mpCleanup = new MemberProv();

            mpCleanup.Initialize("DormouseMembershipProvider", _testConfig);
            foreach (var user in _testUsers)
            {
                mpCleanup.DeleteUser(user.username, true);
            }

            //And our sample role
            var mpRoleCleanup = new RoleProv();

            mpRoleCleanup.Initialize("DormouseMembershipProvider", _testConfig);
            if (mpRoleCleanup.RoleExists("DefaultRole"))
            {
                mpRoleCleanup.DeleteRole("DefaultRole", false);
            }
            foreach (var role in _testRoles)
            {
                if (mpRoleCleanup.RoleExists(role))
                {
                    mpRoleCleanup.DeleteRole(role, false);
                }
            }
        }
        public void TestSetup()
        {
            _mProv = new RoleProv(Utilities.GetMockRepository());
            var config = new NameValueCollection();

            _mProv.Initialize("", config);
        }
        public static void ClassSetup(TestContext testContext)
        {
            //Set up a test configuration to use.
            _testConfig = new NameValueCollection();
            _testConfig.Add("applicationName", "DMTestApp");
            _testUsers = TestUtils.GetTestUsers(2, "Role");
            _testRoles = TestUtils.GetTestRoles(3, "Sample");

            //Clear out old data in case our previous run crashed
            ClassCleanup();

            var mRoleSetup = new RoleProv();

            mRoleSetup.Initialize("DormouseRoleProvider", _testConfig);
            mRoleSetup.CreateRole("DefaultRole");
            foreach (var r in _testRoles)
            {
                mRoleSetup.CreateRole(r);
            }

            var mpSetup = new MemberProv();

            mpSetup.Initialize("DormouseMembershipProvider", _testConfig);
            foreach (var u in _testUsers)
            {
                MembershipCreateStatus status;
                mpSetup.CreateUser(u.username, u.password, u.email, u.passwordQuestion,
                                   u.passwordAnswer, u.isApproved, u.providerUserKey, out status);
            }

            mRoleSetup.AddUsersToRoles(_testUsers.Select(u => u.username).ToArray(), new[] { "DefaultRole" });
        }
        public static void ClassCleanup()
        {
            //We will remove our sample users
            var mpCleanup = new MemberProv();
            mpCleanup.Initialize("DormouseMembershipProvider", _testConfig);
            foreach (var user in _testUsers)
            {
                mpCleanup.DeleteUser(user.username, true);
            }

            //And our sample role
            var mpRoleCleanup = new RoleProv();
            mpRoleCleanup.Initialize("DormouseMembershipProvider", _testConfig);
            if (mpRoleCleanup.RoleExists("DefaultRole"))
            {
                mpRoleCleanup.DeleteRole("DefaultRole", false);
            }
            foreach (var role in _testRoles)
            {
                if (mpRoleCleanup.RoleExists(role))
                {
                    mpRoleCleanup.DeleteRole(role, false);
                }
            }

        }
        public static void ClassSetup(TestContext testContext)
        {
            //Set up a test configuration to use.
            _testConfig = new NameValueCollection();
            _testConfig.Add("applicationName", "DMTestApp");
            _testUsers = TestUtils.GetTestUsers(2, "Role");
            _testRoles = TestUtils.GetTestRoles(3, "Sample");

            //Clear out old data in case our previous run crashed
            ClassCleanup();

            var mRoleSetup = new RoleProv();
            mRoleSetup.Initialize("DormouseRoleProvider", _testConfig);
            mRoleSetup.CreateRole("DefaultRole");
            foreach (var r in _testRoles)
            {
                mRoleSetup.CreateRole(r);
            }

            var mpSetup = new MemberProv();
            mpSetup.Initialize("DormouseMembershipProvider", _testConfig);
            foreach (var u in _testUsers)
            {
                MembershipCreateStatus status;
                mpSetup.CreateUser(u.username, u.password, u.email, u.passwordQuestion,
                    u.passwordAnswer, u.isApproved, u.providerUserKey, out status);
            }

            mRoleSetup.AddUsersToRoles(_testUsers.Select(u=>u.username).ToArray(), new[] { "DefaultRole" });
        }
 public void Initialize_NullConfig_ThrowsArgumentNullException()
 {
     //Arrange
     _mProv = new RoleProv(Utilities.GetMockRepository());
     //Act
     _mProv.Initialize("", null);
     //Assert
 }
        public void Initialize_NullName_SetsDefaultName()
        {
            //Arrange
            _mProv = new RoleProv(Utilities.GetMockRepository());
            //Act
            _mProv.Initialize("", new NameValueCollection());
            var actual = _mProv.ApplicationName;

            //Assert
            Assert.IsNull(actual);
        }
        public void Initialize_AppName_SetsAppName()
        {
            //Arrange
            _mProv = new RoleProv(Utilities.GetMockRepository());
            var expected = "SampleApplication";

            //Act
            _mProv.Initialize("", new NameValueCollection {
                { "applicationName", "SampleApplication" }
            });
            var actual = _mProv.ApplicationName;

            //Assert
            Assert.AreEqual(expected, actual);
        }
 public void TestCleanup()
 {
     _mpRole = null;
 }
 public void TestSetup()
 {
     _mpRole = new RoleProv();
     _mpRole.Initialize("DormouseMembershipProvider", _testConfig);
 }
 public void TestCleanup()
 {
     _mpRole = null;
 }
 public void TestSetup()
 {
     _mpRole = new RoleProv();
     _mpRole.Initialize("DormouseMembershipProvider", _testConfig);
 }