Index: /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs	(revision 3999)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs	(revision 4000)
@@ -54,6 +54,29 @@
     }
 
+    //
+    // RoleProvider.DeleteRole
+    //
     public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) {
-      throw new NotImplementedException();
+      String[] roleArray = new String[1];
+      roleArray[0] = roleName;
+      Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
+
+      if (!RoleExists(roleName)) {
+        return false;
+        //throw new Exception("Role does not exist.");
+      }
+
+      if (throwOnPopulatedRole && GetUsersInRole(roleName).Length > 0) {
+        return false;
+        //throw new ProviderException("Cannot delete a populated role.");
+      }
+
+      RemoveUsersFromRoles(GetUsersInRole(roleName), roleArray);
+
+      Persistence.HeuristicLabRole role = db.HeuristicLabRole.Single(r => r.RoleName == roleName);
+      db.HeuristicLabRole.DeleteOnSubmit(role);
+      db.Dispose();
+
+      return true;
     }
 
@@ -107,5 +130,5 @@
         Persistence.HeuristicLabRole role = context.HeuristicLabRole.Single(r => r.RoleName == roleName);
         foreach (Persistence.HeuristicLabUserRole roleUser in role.HeuristicLabUserRoles) {
-          if(!userList.Contains(roleUser.HeuristicLabUser.UserName))
+          if (!userList.Contains(roleUser.HeuristicLabUser.UserName))
             userList.Add(roleUser.HeuristicLabUser.UserName);
         }
@@ -153,3 +176,3 @@
     }
   }
-}
+}//HeuristicLabRoleProvider
Index: /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs	(revision 3999)
+++ /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs	(revision 4000)
@@ -94,5 +94,5 @@
       //and add all these users to groups admin and users
       AddUsersToRolesTest();
-      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); 
+      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
       string[] users = new string[2];
       string[] roles = new string[1];
@@ -278,12 +278,31 @@
     [TestMethod()]
     public void DeleteRoleTest() {
-      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
-      string roleName = string.Empty; // TODO: Initialize to an appropriate value
-      bool throwOnPopulatedRole = false; // TODO: Initialize to an appropriate value
-      bool expected = false; // TODO: Initialize to an appropriate value
-      bool actual;
-      actual = target.DeleteRole(roleName, throwOnPopulatedRole);
-      Assert.AreEqual(expected, actual);
-      Assert.Inconclusive("Verify the correctness of this test method.");
+
+      //creates users dkhan,hmayer,bfarka (with AddUsersToRolesTest())
+      //and add all these users to groups admin and users
+      AddUsersToRolesTest();
+      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
+      string[] users = new string[2];
+      string[] roles = new string[1];
+
+      //remove hmayer from role admin
+      users[0] = "hmayr";
+      roles[0] = "admin";
+
+      //before removing, check if all three users exits correctly in admin group
+      Assert.IsTrue((target.GetRolesForUser("hmayr").ToList()).Contains(roles[0]));
+      Assert.IsTrue((target.GetRolesForUser("dkhan").ToList()).Contains(roles[0]));
+      Assert.IsTrue((target.GetRolesForUser("bfarka").ToList()).Contains(roles[0]));
+
+      //try to delete Role admin (with user hmayr from  admin group exists)
+      Assert.IsFalse(target.DeleteRole(roles[0], true));
+
+      Assert.IsTrue(target.IsUserInRole(users[0], roles[0]));
+
+      //final populateRole if false
+      //try to delete Role admin (with user hmayr from  admin group exists)
+      Assert.IsTrue(target.DeleteRole(roles[0], false));
+      Assert.IsFalse(target.IsUserInRole(users[0], roles[0]));
+      Assert.IsFalse((target.GetRolesForUser("hmayr").ToList()).Contains(roles[0]));
     }
 
@@ -351,7 +370,7 @@
       try {
         Persistence.HeuristicLabRole role = new Persistence.HeuristicLabRole();
-        role.RoleName ="role1";
+        role.RoleName = "role1";
         Persistence.HeuristicLabRole role1 = new Persistence.HeuristicLabRole();
-        role1.RoleName ="role1";
+        role1.RoleName = "role1";
         db.HeuristicLabRole.InsertOnSubmit(role);
         db.HeuristicLabRole.InsertOnSubmit(role1);
@@ -364,8 +383,3 @@
     }
   }
-
- 
-
-
-
-}
+} //HeuristicLabRoleProviderTest
