Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Services.Authentication Prototype/UnitTests/service/HeuristicLabManagementServiceTest.cs @ 4021

Last change on this file since 4021 was 4021, checked in by bfarka, 14 years ago
File size: 2.0 KB
Line 
1using System;
2using System.Text;
3using System.Collections.Generic;
4using System.Linq;
5using Microsoft.VisualStudio.TestTools.UnitTesting;
6using System.Web.Security;
7using Service.Provider;
8
9namespace UnitTests.service {
10  /// <summary>
11  /// Zusammenfassungsbeschreibung für HeuristicLabManagementServiceTest
12  /// </summary>
13  [TestClass]
14  public class HeuristicLabManagementServiceTest : AbstractHeuristicLabServiceTest {
15   
16
17    private TestContext testContextInstance;
18
19    /// <summary>
20    ///Ruft den Textkontext mit Informationen über
21    ///den aktuellen Testlauf sowie Funktionalität für diesen auf oder legt diese fest.
22    ///</summary>
23    public TestContext TestContext {
24      get {
25        return testContextInstance;
26      }
27      set {
28        testContextInstance = value;
29      }
30    }
31    [TestMethod()]
32    public void TestCreateRoleTest() {
33      MembershipProvider provider = Membership.Provider;
34      MembershipCreateStatus status;
35      provider.CreateUser("testUser", "mypassword", "myMail", "question", "answer", true, null,out status);
36      Assert.AreEqual(MembershipCreateStatus.Success, status);
37      HeuristicLabRoleProvider roleProvider = new HeuristicLabRoleProvider();
38      roleProvider.CreateRole("Admin");
39      roleProvider.AddUsersToRoles(new String[1]{"testUser"},new String[1]{"Admin"});
40
41      AuthorizationManagementServiceRemote.AuthorizationManagementServiceClient client = new AuthorizationManagementServiceRemote.AuthorizationManagementServiceClient();
42      client.ClientCredentials.UserName.UserName = "testUser";
43      client.ClientCredentials.UserName.Password = "mypassword";
44      client.CreateRole("roleName", true);
45      roleProvider.RemoveUsersFromRoles(new String[1] { "testUser" }, new String[1] { "Admin" });
46      try {
47        client.CreateRole("roleName", true);
48        Assert.Fail();
49      }
50      catch (Exception) {
51        //should throw exception
52      }
53
54
55    }
56
57   
58  }
59}
Note: See TracBrowser for help on using the repository browser.