Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/10 13:48:48 (14 years ago)
Author:
mholper
Message:

implemented last Method HeuristicLabRoleProvider.DeleteRole and UnitTest (#1046)
--> HeuristicLabRoleProvider finished now, all HeuristicLabRoleProviderTest passed (#1077)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs

    r3978 r4000  
    9494      //and add all these users to groups admin and users
    9595      AddUsersToRolesTest();
    96       HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); 
     96      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
    9797      string[] users = new string[2];
    9898      string[] roles = new string[1];
     
    278278    [TestMethod()]
    279279    public void DeleteRoleTest() {
    280       HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
    281       string roleName = string.Empty; // TODO: Initialize to an appropriate value
    282       bool throwOnPopulatedRole = false; // TODO: Initialize to an appropriate value
    283       bool expected = false; // TODO: Initialize to an appropriate value
    284       bool actual;
    285       actual = target.DeleteRole(roleName, throwOnPopulatedRole);
    286       Assert.AreEqual(expected, actual);
    287       Assert.Inconclusive("Verify the correctness of this test method.");
     280
     281      //creates users dkhan,hmayer,bfarka (with AddUsersToRolesTest())
     282      //and add all these users to groups admin and users
     283      AddUsersToRolesTest();
     284      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
     285      string[] users = new string[2];
     286      string[] roles = new string[1];
     287
     288      //remove hmayer from role admin
     289      users[0] = "hmayr";
     290      roles[0] = "admin";
     291
     292      //before removing, check if all three users exits correctly in admin group
     293      Assert.IsTrue((target.GetRolesForUser("hmayr").ToList()).Contains(roles[0]));
     294      Assert.IsTrue((target.GetRolesForUser("dkhan").ToList()).Contains(roles[0]));
     295      Assert.IsTrue((target.GetRolesForUser("bfarka").ToList()).Contains(roles[0]));
     296
     297      //try to delete Role admin (with user hmayr from  admin group exists)
     298      Assert.IsFalse(target.DeleteRole(roles[0], true));
     299
     300      Assert.IsTrue(target.IsUserInRole(users[0], roles[0]));
     301
     302      //final populateRole if false
     303      //try to delete Role admin (with user hmayr from  admin group exists)
     304      Assert.IsTrue(target.DeleteRole(roles[0], false));
     305      Assert.IsFalse(target.IsUserInRole(users[0], roles[0]));
     306      Assert.IsFalse((target.GetRolesForUser("hmayr").ToList()).Contains(roles[0]));
    288307    }
    289308
     
    351370      try {
    352371        Persistence.HeuristicLabRole role = new Persistence.HeuristicLabRole();
    353         role.RoleName ="role1";
     372        role.RoleName = "role1";
    354373        Persistence.HeuristicLabRole role1 = new Persistence.HeuristicLabRole();
    355         role1.RoleName ="role1";
     374        role1.RoleName = "role1";
    356375        db.HeuristicLabRole.InsertOnSubmit(role);
    357376        db.HeuristicLabRole.InsertOnSubmit(role1);
     
    364383    }
    365384  }
    366 
    367  
    368 
    369 
    370 
    371 }
     385} //HeuristicLabRoleProviderTest
Note: See TracChangeset for help on using the changeset viewer.