Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3953


Ignore:
Timestamp:
06/25/10 23:34:51 (14 years ago)
Author:
bfarka
Message:

implemented one more function and a unittest for it (#1046)

Location:
branches/HeuristicLab.Services.Authentication Prototype
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/HeuristicLab.Services.Authentication Prototyp.sln

    r3932 r3953  
    1111  ProjectSection(SolutionItems) = preProject
    1212    HeuristicLab.Services.Authentication Prototyp.vsmdi = HeuristicLab.Services.Authentication Prototyp.vsmdi
     13    HeuristicLab.Services.Authentication Prototyp1.vsmdi = HeuristicLab.Services.Authentication Prototyp1.vsmdi
    1314    LocalTestRun.testrunconfig = LocalTestRun.testrunconfig
    1415  EndProjectSection
     
    1617Global
    1718  GlobalSection(TestCaseManagementSettings) = postSolution
    18     CategoryFile = HeuristicLab.Services.Authentication Prototyp.vsmdi
     19    CategoryFile = HeuristicLab.Services.Authentication Prototyp1.vsmdi
    1920  EndGlobalSection
    2021  GlobalSection(SolutionConfigurationPlatforms) = preSolution
  • branches/HeuristicLab.Services.Authentication Prototype/HeuristicLab.Services.Authentication Prototyp.vsmdi

    r3952 r3953  
    1 <?xml version="1.0" encoding="UTF-8"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">
    33  <TestList name="HeuristicLabRoleProviderTestList" id="5d68832d-33e3-456f-94dc-5fcdb20ad3fe" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
     
    2828    </TestLinks>
    2929  </TestList>
     30  <TestList name="RoleProviderTest" id="5163da73-f948-4da0-ac41-d4a3a5eb1677" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
     31      <TestLinks>
     32        <TestLink id="3463a5ed-c3f1-6729-be85-dc5e0d4df6bd" name="CreateRoleTest" storage="unittests\bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" />
     33        <TestLink id="b076f1b4-7085-972e-6b44-f9169d06d257" name="HeuristicLabRoleProviderConstructorTest" storage="unittests\bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" />
     34        <TestLink id="903719dc-469b-6714-449e-0d776b005bcf" name="RoleExistsTest" storage="unittests\bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" />
     35      </TestLinks>
     36  </TestList>
    3037</TestLists>
  • branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs

    r3952 r3953  
    2222
    2323    public override void CreateRole(string roleName) {
    24       throw new NotImplementedException();
     24      CreateRole(roleName, false);
     25
     26    }
     27
     28    public virtual void CreateRole(String roleName, bool isPermission) {
     29      Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
     30      HeuristicLabRole role = new HeuristicLabRole();
     31      role.RoleName = roleName;
     32      role.IsPermission = isPermission;
     33      db.HeuristicLabRole.InsertOnSubmit(role);
     34      db.SubmitChanges();
    2535    }
    2636
     
    3040
    3141    public override string[] FindUsersInRole(string roleName, string usernameToMatch) {
    32       throw new NotImplementedException();
     42      throw new NotImplementedException("not implemented");
    3343    }
    3444
     
    7585      Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
    7686      bool returnValue = (DatabaseUtil.createDataClassesDataContext().HeuristicLabRole.Count(r => r.RoleName == roleName) == 1);
    77       db.Connection.Close();
     87      db.Dispose();
    7888      return returnValue;
    7989
  • branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs

    r3952 r3953  
    11using Service.Provider;
    22using Microsoft.VisualStudio.TestTools.UnitTesting;
     3using System.Linq;
    34namespace UnitTests {
    45  /// <summary>
     
    7677      Persistence.HeuristicLabRole role = new Persistence.HeuristicLabRole();
    7778      role.RoleName = TEST_ROLE_NAME;
    78       Persistence.DataClassesDataContext db = Persistence.DatabaseUtil.createDataClassesDataContext();
    7979      db.HeuristicLabRole.InsertOnSubmit((Persistence.HeuristicLabRole)role);
    8080      db.SubmitChanges();
     
    186186    [TestMethod()]
    187187    public void CreateRoleTest() {
    188       HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
    189       string roleName = string.Empty; // TODO: Initialize to an appropriate value
    190       target.CreateRole(roleName);
    191       Assert.Inconclusive("A method that does not return a value cannot be verified.");
     188      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
     189      target.CreateRole("role1");
     190      target.CreateRole("role2");
     191      target.CreateRole("role3", true);
     192      Assert.IsTrue(db.HeuristicLabRole.Count(r => r.RoleName == "role1" && r.IsPermission == false) == 1);
     193      Assert.IsTrue(db.HeuristicLabRole.Count(r => r.RoleName == "role2" && r.IsPermission == false) == 1);
     194      Assert.IsTrue(db.HeuristicLabRole.Count(r => r.RoleName == "role3" && r.IsPermission == true) == 1);
    192195    }
    193196
     
    210213    public void HeuristicLabRoleProviderConstructorTest() {
    211214      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
    212       Assert.Inconclusive("TODO: Implement code to verify target");
     215      Assert.IsNotNull(target);
    213216    }
    214217  }
Note: See TracChangeset for help on using the changeset viewer.