Esempio n. 1
0
        public void AddUserToRole()
        {
            roleProvider = new MySQLRoleProvider();
            NameValueCollection config = new NameValueCollection();

            config.Add("connectionStringName", "LocalMySqlServer");
            config.Add("applicationName", "/");
            roleProvider.Initialize(null, config);

            AddUser("eve", "eveeve!");
            roleProvider.CreateRole("Administrator");

            roleProvider.AddUsersToRoles(new string[] { "eve" },
                                         new string[] { "Administrator" });
            Assert.True(roleProvider.IsUserInRole("eve", "Administrator"));

            roleProvider.RemoveUsersFromRoles(new string[] { "eve" }, new string[] { "Administrator" });
            Assert.False(roleProvider.IsUserInRole("eve", "Administrator"));

            roleProvider.DeleteRole("Administrator", false);
            Assert.Equal(0, roleProvider.GetAllRoles().Length);

            //clean up
            membershipProvider.DeleteUser("eve", true);
        }
Esempio n. 2
0
        public void AddUserToRole()
        {
            AddUser("eve", "eveeve!");
            roleProvider.CreateRole("Administrator");

            roleProvider.AddUsersToRoles(new string[] { "eve" },
                                         new string[] { "Administrator" });
            Assert.True(roleProvider.IsUserInRole("eve", "Administrator"));

            roleProvider.RemoveUsersFromRoles(new string[] { "eve" }, new string[] { "Administrator" });
            Assert.False(roleProvider.IsUserInRole("eve", "Administrator"));

            roleProvider.DeleteRole("Administrator", false);
            Assert.AreEqual(0, roleProvider.GetAllRoles().Length);

            //clean up
            membershipProvider.DeleteUser("eve", true);
        }
Esempio n. 3
0
        public void AddUserToRole()
        {
            roleProvider = new MySQLRoleProvider();
            NameValueCollection config = new NameValueCollection();

            config.Add("connectionStringName", "LocalMySqlServer");
            config.Add("applicationName", "/");
            roleProvider.Initialize(null, config);

            AddUser("eve", "eveeve!");
            roleProvider.CreateRole("Administrator");
            roleProvider.AddUsersToRoles(new string[] { "eve" },
                                         new string[] { "Administrator" });
            Assert.IsTrue(roleProvider.IsUserInRole("eve", "Administrator"));

            roleProvider.RemoveUsersFromRoles(new string[] { "eve" }, new string[] { "Administrator" });
            Assert.IsFalse(roleProvider.IsUserInRole("eve", "Administrator"));
        }