Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/26/10 12:51:55 (14 years ago)
Author:
mholper
Message:

implemented RoleProvider.IsUserInRole (#1046)

File:
1 edited

Legend:

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

    r3960 r3963  
    1212    private TestContext testContextInstance;
    1313    private const string TEST_ROLE_NAME = "testRole";
     14    private const string TEST_USER_NAME = "testUser";
    1415    /// <summary>
    1516    ///Gets or sets the test context which provides
     
    9697
    9798    /// <summary>
    98     ///A test for IsUserInRole
     99    /// test if user is in Role (positive and negative Assertion)
    99100    ///</summary>
    100101    [TestMethod()]
    101102    public void IsUserInRoleTest() {
    102       HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
    103       string username = string.Empty; // TODO: Initialize to an appropriate value
    104       string roleName = string.Empty; // TODO: Initialize to an appropriate value
    105       bool expected = false; // TODO: Initialize to an appropriate value
    106       bool actual;
    107       actual = target.IsUserInRole(username, roleName);
    108       Assert.AreEqual(expected, actual);
    109       Assert.Inconclusive("Verify the correctness of this test method.");
     103        HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
     104        Dictionary<string, Persistence.HeuristicLabUser> users = new Dictionary<string, Persistence.HeuristicLabUser>();
     105        List<string> roles = new List<string>();
     106        users.Add("mholper", new Persistence.HeuristicLabUser("mholper", "foo", "password", "comment"));
     107
     108        roles.Add("admin");
     109        roles.Add("users");
     110        foreach (string role in roles)
     111        {
     112            target.CreateRole(role);
     113        }
     114        foreach (Persistence.HeuristicLabUser user in users.Values)
     115        {
     116            db.HeuristicLabUsers.InsertOnSubmit(user);
     117        }
     118        db.SubmitChanges();
     119        string[] rolesToTest = new string[1];
     120        rolesToTest[0] = "admin";
     121        target.AddUsersToRoles(users.Keys.ToArray(), rolesToTest); // roles.ToArray());
     122        Assert.IsTrue(target.IsUserInRole("mholper", "admin"));
     123        Assert.IsFalse(target.IsUserInRole("mholper", "user"));
    110124    }
    111125
Note: See TracChangeset for help on using the changeset viewer.