Ejemplo n.º 1
0
        public void AddAndRemoveMultipleUsersToARole()
        {
            byte[] password = ASCIIEncoding.ASCII.GetBytes("123");

            manager.CreateUser("user1", password);
            manager.CreateUser("user2", password);
            manager.CreateUser("user3", password);
            manager.CreateRole(roleName);
            manager.CreateRole(roleName2);

            // create batch
            manager.CreateUserRoleBatch(GetBatchData());
            DataSet ds = SelectUserRoles("user1");

            Assert.AreEqual(2, ds.Tables[0].Rows.Count);
            Assert.AreEqual(roleName, ds.Tables[0].Rows[0]["RoleName"]);
            Assert.AreEqual(roleName2, ds.Tables[0].Rows[1]["RoleName"]);

            ds = SelectUserRoles("user2");
            Assert.AreEqual(1, ds.Tables[0].Rows.Count);
            Assert.AreEqual(roleName, ds.Tables[0].Rows[0]["RoleName"]);

            ds = SelectUserRoles("user3");
            Assert.AreEqual(1, ds.Tables[0].Rows.Count);
            Assert.AreEqual(roleName, ds.Tables[0].Rows[0]["RoleName"]);

            // delete batch
            manager.DeleteUserRoleBatch(GetBatchData());
            ds = SelectUserRoles("user1");
            Assert.AreEqual(0, ds.Tables[0].Rows.Count);

            ds = SelectUserRoles("user2");
            Assert.AreEqual(0, ds.Tables[0].Rows.Count);

            ds = SelectUserRoles("user3");
            Assert.AreEqual(0, ds.Tables[0].Rows.Count);

            manager.DeleteRole(roleName);
            manager.DeleteRole(roleName2);
            manager.DeleteUser("user1");
            manager.DeleteUser("user2");
            manager.DeleteUser("user3");
        }
Ejemplo n.º 2
0
 private void DeleteUserRoleBatchDelegate(params object[] methodParams)
 {
     manager.DeleteUserRoleBatch((DataTable)methodParams[0]);
 }