Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs	(revision 3954)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs	(revision 3955)
@@ -11,12 +11,5 @@
     /// <returns>database connection (could be null)</returns>
     public static DataClassesDataContext createDataClassesDataContext() {
-      DataClassesDataContext db;
-      try {
-        db = new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTest.mdf");
-      }
-      catch (Exception) {
-        return null;
-      }
-      return db;
+        return  new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTest.mdf");
     }
 
Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUserRole.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUserRole.cs	(revision 3955)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUserRole.cs	(revision 3955)
@@ -0,0 +1,12 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Persistence {
+  partial class HeuristicLabUserRole {
+    public override bool Equals(object obj) {
+      return ((HeuristicLabUserRole)obj).HeuristicLabRole.Equals(this.HeuristicLabRole) && ((HeuristicLabUserRole)obj).HeuristicLabUser.Equals(this.HeuristicLabUser);
+    }
+  }
+}
Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/Persistence.csproj
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/Persistence.csproj	(revision 3954)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/Persistence.csproj	(revision 3955)
@@ -50,4 +50,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="HeuristicLabUserRole.cs" />
     <Compile Include="DatabaseUtil.cs" />
     <Compile Include="DataClasses.designer.cs">
Index: /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs	(revision 3954)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs	(revision 3955)
@@ -8,14 +8,31 @@
 namespace Service.Provider {
   class HeuristicLabRoleProvider : RoleProvider {
+    protected string applicationName;
+
     public override void AddUsersToRoles(string[] usernames, string[] roleNames) {
-      throw new NotImplementedException();
+      if (usernames != null && roleNames != null) {
+        Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
+        List<HeuristicLabUser> users = db.HeuristicLabUsers.Where(u => usernames.Contains(u.UserName)).ToList<HeuristicLabUser>();
+        List<HeuristicLabRole> roles = db.HeuristicLabRole.Where(r => roleNames.Contains(r.RoleName)).ToList<HeuristicLabRole>();
+        foreach (HeuristicLabUser user in users) {
+          foreach (HeuristicLabRole role in roles) {
+            HeuristicLabUserRole userRole = new HeuristicLabUserRole();
+            userRole.HeuristicLabRole = role;
+            userRole.HeuristicLabUser = user;
+
+            db.HeuristicLabUserRole.InsertOnSubmit(userRole);
+
+          }
+        }
+        db.SubmitChanges();
+      }
     }
 
     public override string ApplicationName {
       get {
-        throw new NotImplementedException();
+        return this.applicationName;
       }
       set {
-        throw new NotImplementedException();
+        this.applicationName = value;
       }
     }
@@ -27,10 +44,12 @@
 
     public virtual void CreateRole(String roleName, bool isPermission) {
-      Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
-      HeuristicLabRole role = new HeuristicLabRole();
-      role.RoleName = roleName;
-      role.IsPermission = isPermission;
-      db.HeuristicLabRole.InsertOnSubmit(role);
-      db.SubmitChanges();
+      if (roleName != null) {
+        Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
+        HeuristicLabRole role = new HeuristicLabRole();
+        role.RoleName = roleName;
+        role.IsPermission = isPermission;
+        db.HeuristicLabRole.InsertOnSubmit(role);
+        db.SubmitChanges();
+      }
     }
 
@@ -44,11 +63,10 @@
       if (roleName != null && db.HeuristicLabRole.Count(r => r.RoleName == roleName) == 1) {
         HeuristicLabRole role = db.HeuristicLabRole.Single(r => r.RoleName == roleName);
-        foreach(HeuristicLabUserRole userRole in role.HeuristicLabUserRole)
-        {
+        foreach (HeuristicLabUserRole userRole in role.HeuristicLabUserRole) {
           if (userRole.HeuristicLabUser.UserName.Contains(usernameToMatch)) {
             returnValue.Add(userRole.HeuristicLabUser.UserName);
           }
         }
-       }
+      }
       db.Dispose();
       return returnValue.ToArray();
@@ -59,6 +77,5 @@
 
       List<HeuristicLabRole> roles = new List<HeuristicLabRole>(DatabaseUtil.createDataClassesDataContext().HeuristicLabRole.Select(r => r));
-      foreach(HeuristicLabRole r in roles)
-      {
+      foreach (HeuristicLabRole r in roles) {
         roleList.Add(r.RoleName);
       }
@@ -71,5 +88,5 @@
       DataClassesDataContext context = DatabaseUtil.createDataClassesDataContext();
       if (username != null && context.HeuristicLabUsers.Count(u => u.UserName == username) > 0) {
-       
+
         Persistence.HeuristicLabUser user = context.HeuristicLabUsers.Single(u => u.UserName == username);
         foreach (Persistence.HeuristicLabUserRole userRole in user.HeuristicLabUserRole) {
Index: /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs	(revision 3954)
+++ /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs	(revision 3955)
@@ -2,4 +2,5 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using System.Linq;
+using System.Collections.Generic;
 namespace UnitTests {
   /// <summary>
@@ -60,11 +61,10 @@
     [TestMethod()]
     public void ApplicationNameTest() {
-      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
-      string expected = string.Empty; // TODO: Initialize to an appropriate value
+      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
+      string expected = "JavaIsEvenCooler";
       string actual;
       target.ApplicationName = expected;
       actual = target.ApplicationName;
       Assert.AreEqual(expected, actual);
-      Assert.Inconclusive("Verify the correctness of this test method.");
     }
 
@@ -143,10 +143,20 @@
     [TestMethod()]
     public void GetAllRolesTest() {
-      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
-      string[] expected = null; // TODO: Initialize to an appropriate value
-      string[] actual;
-      actual = target.GetAllRoles();
-      Assert.AreEqual(expected, actual);
-      Assert.Inconclusive("Verify the correctness of this test method.");
+      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); 
+      List<string> roleNames = new List<string>();
+      roleNames.Add("Pascal");
+      roleNames.Add("Java");
+      roleNames.Add("Pascal");
+      roleNames.Add("VisalBasic");
+      foreach (string s in roleNames) {
+        target.CreateRole(s);
+      }
+      target.CreateRole(null);
+      string[] roles = target.GetAllRoles();
+      foreach(string role in roles)
+      {
+        Assert.IsTrue(roleNames.Remove(role));
+      }
+      Assert.IsTrue(roleNames.Count == 0);
     }
 
@@ -195,4 +205,11 @@
     }
 
+    protected int getUserRolesCount() {
+      return db.HeuristicLabUserRole.Count();
+            
+     
+    }
+
+
     /// <summary>
     ///A test for AddUsersToRoles
@@ -201,8 +218,29 @@
     public void AddUsersToRolesTest() {
       HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
-      string[] usernames = null; // TODO: Initialize to an appropriate value
-      string[] roleNames = null; // TODO: Initialize to an appropriate value
-      target.AddUsersToRoles(usernames, roleNames);
-      Assert.Inconclusive("A method that does not return a value cannot be verified.");
+      Dictionary<string, Persistence.HeuristicLabUser> users = new Dictionary<string, Persistence.HeuristicLabUser>();
+      List<string> roles = new List<string>();
+      users.Add("dkhan", new Persistence.HeuristicLabUser("dkhan", "foo", "password", "comment"));
+      users.Add("hmayr", new Persistence.HeuristicLabUser("hmayr", "foo", "password", "comment"));
+      users.Add("bfarka", new Persistence.HeuristicLabUser("bfarka", "foo", "password", "comment"));
+
+      roles.Add("admin");
+      roles.Add("users");
+      //testing to create roles with users that doesn't exists
+      target.AddUsersToRoles(users.Keys.ToArray(), roles.ToArray());
+      Assert.IsTrue(getUserRolesCount() == 0);
+
+      foreach (string role in roles)
+      {
+        target.CreateRole(role);
+      }
+      target.AddUsersToRoles(users.Keys.ToArray(), roles.ToArray());
+      Assert.IsTrue(getUserRolesCount() == 0);
+      foreach (Persistence.HeuristicLabUser user in users.Values) {
+        db.HeuristicLabUsers.InsertOnSubmit(user);
+      }
+      db.SubmitChanges();
+      target.AddUsersToRoles(users.Keys.ToArray(), roles.ToArray());
+      Assert.IsTrue(getUserRolesCount() == (roles.Count + users.Count));
+
     }
 
