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 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 CreateRole_GivenNull_ThrowsException()
 {
     //Arrange
     //Act
     _mProv.CreateRole(null);
     //Assert
     Assert.Fail();
 }
        public void CreateRole_GivenGoodRole_AddsRole()
        {
            //Arrange
            //Act
            _mpRole.CreateRole("SampleToAdd");
            var actual = _mpRole.RoleExists("SampleToAdd");

            _mpRole.DeleteRole("SampleToAdd", false);
            //Assert
            Assert.IsTrue(actual);
        }