Exemplo n.º 1
0
        public void ShouldBeAbleToCreateAndDeleteRole()
        {
            DaoRoleProvider provider = new DaoRoleProvider();

            Expect.IsFalse(provider.RoleExists(roleName), "Role should not have existed: {0}"._Format(roleName));
            provider.CreateRole(roleName);
            Expect.IsTrue(provider.RoleExists(roleName), "Role didn't get created");
            provider.DeleteRole(roleName, false);
            Expect.IsFalse(provider.RoleExists(roleName), "Role didn't get deleted");
        }
Exemplo n.º 2
0
        public void ShouldBeAbleToAddUsersToRole()
        {
            User user = User.Ensure(userName);

            DaoRoleProvider provider = new DaoRoleProvider();

            provider.DeleteRole(roleName, false);
            Expect.IsFalse(provider.RoleExists(roleName));
            provider.CreateRole(roleName);

            Expect.IsFalse(provider.IsUserInRole(userName, roleName));
            provider.AddUsersToRoles(new string[] { userName }, new string[] { roleName });

            Expect.IsTrue(provider.IsUserInRole(userName, roleName), "user wasn't added to role");

            provider.DeleteRole(roleName, false);
        }