Exemple #1
0
        public void DeleteRoleTest4()
        {
            try {
                RainbowRoleProvider provider = Roles.Provider as RainbowRoleProvider;

                RainbowRole editors = provider.GetRoleByName("Rainbow", "editors");
                provider.DeleteRole("invalidApp", editors.Id, true);
                Assert.Fail();
            }
            catch (RainbowRoleProviderException) {}
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Assert.Fail("Error in DeleteRoleTest4" + ex.Message, ex);
            }
        }
Exemple #2
0
        public void AddUsersToRolesTest6()
        {
            try {
                RainbowRoleProvider provider = Roles.Provider as RainbowRoleProvider;

                RainbowUser user  = ( RainbowUser )Membership.GetUser("*****@*****.**");
                Guid[]      users = new Guid[1];
                users[0] = user.ProviderUserKey;

                RainbowRole role  = provider.GetRoleByName("Rainbow", "clerks");
                Guid[]      roles = new Guid[1];
                roles[0] = role.Id;

                provider.AddUsersToRoles("Rainbow", users, roles);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Assert.Fail("Error in AddUsersToRolesTest6" + ex.Message, ex);
            }
        }
Exemple #3
0
        public void RemoveUsersFromRolesTest6()
        {
            try {
                RainbowRoleProvider provider = Roles.Provider as RainbowRoleProvider;

                Guid[] users = new Guid[1];
                users[0] = new Guid("BE7DC028-7238-45D3-AF35-DD3FE4AEFB7E");     //"*****@*****.**";

                RainbowRole editors = provider.GetRoleByName("Rainbow", "salesman");
                Guid[]      roles   = new Guid[1];
                roles[0] = editors.Id;

                provider.RemoveUsersFromRoles("Rainbow", users, roles);
                Assert.Fail();
            }
            catch (RainbowRoleProviderException) {}
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Assert.Fail("Error in RemoveUsersFromRolesTest6" + ex.Message, ex);
            }
        }
Exemple #4
0
        public void RemoveUsersFromRolesTest7()
        {
            try {
                RainbowRoleProvider provider = Roles.Provider as RainbowRoleProvider;

                Guid userId = new Guid("34ADB714-92B0-47ff-B5AF-5DB2E0D124A9");   // [email protected];

                Guid[] users = new Guid[] { userId };

                RainbowRole editors = provider.GetRoleByName("Rainbow", "editors");
                Guid[]      roles   = new Guid[1];
                roles[0] = editors.Id;

                provider.AddUsersToRoles("Rainbow", users, roles);
                Assert.IsTrue(provider.IsUserInRole("Rainbow", userId, editors.Id));

                provider.RemoveUsersFromRoles("Rainbow", users, roles);
                Assert.IsFalse(provider.IsUserInRole("Rainbow", userId, editors.Id));
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Assert.Fail("Error in RemoveUsersFromRolesTest7" + ex.Message, ex);
            }
        }