Changeset 5335
- Timestamp:
- 01/19/11 18:09:40 (14 years ago)
- Location:
- branches/ClientManagement/HeuristicLab.Services.Authentication
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataTransfer/Client.cs
r4731 r5335 1 1 using System.Runtime.Serialization; 2 2 3 namespace HeuristicLab.Services.Authentication.DataTransfer 4 { 5 [DataContract] 6 public class Client : HeuristicLab.Services.Authentication.DataTransfer.Resource 7 { 8 [DataMember] 9 public string ProcessorType { get; set; } 10 [DataMember] 11 public string NumberOfProcessors { get; set; } 12 [DataMember] 13 public string NumberOfThreads { get; set; } 14 [DataMember] 15 public string IPAdress { get; set; } 16 [DataMember] 17 public string MemorySize { get; set; } 18 [DataMember] 19 public string OperatingSystem { get; set; } 3 namespace HeuristicLab.Services.Authentication.DataTransfer { 4 [DataContract] 5 public class Client : HeuristicLab.Services.Authentication.DataTransfer.Resource { 6 [DataMember] 7 public string ProcessorType { get; set; } 8 [DataMember] 9 public string NumberOfProcessors { get; set; } 10 [DataMember] 11 public string NumberOfThreads { get; set; } 12 [DataMember] 13 public string IPAdress { get; set; } 14 [DataMember] 15 public string MemorySize { get; set; } 16 [DataMember] 17 public string OperatingSystem { get; set; } 20 18 21 19 } 22 20 } -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataTransfer/Resource.cs
r4953 r5335 1 1 using System.Runtime.Serialization; 2 using System.Collections.Generic; 2 3 3 namespace HeuristicLab.Services.Authentication.DataTransfer 4 { 5 [DataContract]6 public abstract class Resource7 { 8 9 10 11 12 13 14 15 public stringResourceType { get; set; }16 17 public System.GuidResourceGroup { get; set; }18 4 namespace HeuristicLab.Services.Authentication.DataTransfer { 5 [DataContract] 6 public abstract class Resource { 7 public enum ResourceTypes { Client, ResourceGroup }; 8 9 [DataMember] 10 public System.Guid Id { get; set; } 11 [DataMember] 12 public string Name { get; set; } 13 [DataMember] 14 public string Description { get; set; } 15 [DataMember] 16 public ResourceTypes ResourceType { get; set; } 17 [DataMember] 18 public IEnumerable<System.Guid> ResourceGroup { get; set; } 19 } 19 20 } 20 21 -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataTransfer/ResourceGroup.cs
r4731 r5335 1 1 using System.Runtime.Serialization; 2 2 3 namespace HeuristicLab.Services.Authentication.DataTransfer 4 { 5 [DataContract] 6 public class ResourceGroup : Resource 7 { 8 } 3 namespace HeuristicLab.Services.Authentication.DataTransfer { 4 [DataContract] 5 public class ResourceGroup : Resource { 6 } 9 7 } 10 8 -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/Convert.cs
r4953 r5335 24 24 using DA = HeuristicLab.Services.Authentication.DataAccess; 25 25 using DT = HeuristicLab.Services.Authentication.DataTransfer; 26 using System; 26 27 27 namespace HeuristicLab.Services.Authentication 28 { 29 public static class Convert 30 { 28 namespace HeuristicLab.Services.Authentication { 29 public static class Convert { 31 30 32 #region Client 33 public static DT.Client ToDto(DA.Client source) 34 { 35 if (source == null) return null; 36 return new DT.Client 37 { 38 Id = source.Id, 39 Name = source.Name, 40 Description = source.Description, 41 ResourceType = source.ResourceType, 42 ProcessorType = source.ProcessorType, 43 NumberOfProcessors = source.NumberOfProcessors, 44 NumberOfThreads = source.NumberOfThreads, 45 IPAdress = source.IPAdress, 46 MemorySize = source.MemorySize, 47 OperatingSystem = source.OperatingSystem 48 }; 49 } 31 #region Client 32 public static DT.Client ToDto(DA.Client source) { 33 if (source == null) return null; 34 return new DT.Client { 35 Id = source.Id, 36 Name = source.Name, 37 Description = source.Description, 38 ResourceType = (DT.Resource.ResourceTypes) Enum.Parse(typeof(DT.Resource.ResourceTypes), source.ResourceType), 39 ProcessorType = source.ProcessorType, 40 NumberOfProcessors = source.NumberOfProcessors, 41 NumberOfThreads = source.NumberOfThreads, 42 IPAdress = source.IPAdress, 43 MemorySize = source.MemorySize, 44 OperatingSystem = source.OperatingSystem 45 }; 46 } 50 47 51 public static DA.Client ToEntity(DT.Client source) 52 { 53 if (source == null) return null; 54 return new DA.Client 55 { 56 Id = source.Id, 57 Name = source.Name, 58 Description = source.Description, 59 ResourceType = source.ResourceType, 60 ProcessorType = source.ProcessorType, 61 NumberOfProcessors = source.NumberOfProcessors, 62 NumberOfThreads = source.NumberOfThreads, 63 IPAdress = source.IPAdress, 64 MemorySize = source.MemorySize, 65 OperatingSystem = source.OperatingSystem 66 }; 67 } 48 public static DA.Client ToEntity(DT.Client source) { 49 if (source == null) return null; 50 return new DA.Client { 51 Id = source.Id, 52 Name = source.Name, 53 Description = source.Description, 54 ResourceType = source.ResourceType.ToString(), 55 ProcessorType = source.ProcessorType, 56 NumberOfProcessors = source.NumberOfProcessors, 57 NumberOfThreads = source.NumberOfThreads, 58 IPAdress = source.IPAdress, 59 MemorySize = source.MemorySize, 60 OperatingSystem = source.OperatingSystem 61 }; 62 } 68 63 69 public static DA.Resource ToEntity(DT.Resource source) 70 { 71 if (source == null) return null; 72 if (source is DT.Client) 73 { 74 DT.Client client = (Client) source; 75 return ToEntity(client); 76 } 77 if (source is DT.ResourceGroup) 78 { 79 DT.ResourceGroup resourceGroup = (ResourceGroup) source; 80 return ToEntity(resourceGroup); 81 } 82 return null; 83 } 64 public static DA.Resource ToEntity(DT.Resource source) { 65 if (source == null) return null; 66 if (source is DT.Client) { 67 DT.Client client = (Client)source; 68 return ToEntity(client); 69 } 70 if (source is DT.ResourceGroup) { 71 DT.ResourceGroup resourceGroup = (ResourceGroup)source; 72 return ToEntity(resourceGroup); 73 } 74 return null; 75 } 84 76 85 public static void ToEntity(DT.Client source, DA.Client target) 86 { 87 if ((source != null) && (target != null)) 88 { 89 target.Id = source.Id; 90 target.Name = source.Name; 91 target.Description = source.Description; 92 target.ResourceType = source.ResourceType; 93 target.ProcessorType = source.ProcessorType; 94 target.NumberOfProcessors = source.NumberOfProcessors; 95 target.NumberOfThreads = source.NumberOfThreads; 96 target.IPAdress = source.IPAdress; 97 target.MemorySize = source.MemorySize; 98 target.OperatingSystem = source.OperatingSystem; 99 } 100 } 101 #endregion // Client 77 public static void ToEntity(DT.Client source, DA.Client target) { 78 if ((source != null) && (target != null)) { 79 target.Id = source.Id; 80 target.Name = source.Name; 81 target.Description = source.Description; 82 target.ResourceType = source.ResourceType.ToString(); 83 target.ProcessorType = source.ProcessorType; 84 target.NumberOfProcessors = source.NumberOfProcessors; 85 target.NumberOfThreads = source.NumberOfThreads; 86 target.IPAdress = source.IPAdress; 87 target.MemorySize = source.MemorySize; 88 target.OperatingSystem = source.OperatingSystem; 89 } 90 } 91 #endregion // Client 102 92 103 #region ResourceGroup 104 public static DT.ResourceGroup ToDto(DA.ResourceGroup source) 105 { 106 if (source == null) return null; 107 return new DT.ResourceGroup 108 { 109 Id = source.Id, 110 Name = source.Name, 111 Description = source.Description, 112 ResourceType = source.ResourceType, 113 }; 114 } 93 #region ResourceGroup 94 public static DT.ResourceGroup ToDto(DA.ResourceGroup source) { 95 if (source == null) return null; 96 return new DT.ResourceGroup { 97 Id = source.Id, 98 Name = source.Name, 99 Description = source.Description, 100 ResourceType = (DT.Resource.ResourceTypes)Enum.Parse(typeof(DT.Resource.ResourceTypes), source.ResourceType) 101 }; 102 } 115 103 116 public static DA.ResourceGroup ToEntity(DT.ResourceGroup source) 117 { 118 if (source == null) return null; 119 return new DA.ResourceGroup 120 { 121 Id = source.Id, 122 Name = source.Name, 123 Description = source.Description, 124 ResourceType = source.ResourceType, 125 }; 126 } 104 public static DA.ResourceGroup ToEntity(DT.ResourceGroup source) { 105 if (source == null) return null; 106 return new DA.ResourceGroup { 107 Id = source.Id, 108 Name = source.Name, 109 Description = source.Description, 110 ResourceType = source.ResourceType.ToString() 111 }; 112 } 127 113 128 public static void ToEntity(DT.ResourceGroup source, DA.ResourceGroup target) 129 { 130 if ((source != null) && (target != null)) 131 { 132 target.Id = source.Id; 133 target.Name = source.Name; 134 target.Description = source.Description; 135 target.ResourceType = source.ResourceType; 136 } 137 } 138 #endregion // ResourceGroup 114 public static void ToEntity(DT.ResourceGroup source, DA.ResourceGroup target) { 115 if ((source != null) && (target != null)) { 116 target.Id = source.Id; 117 target.Name = source.Name; 118 target.Description = source.Description; 119 target.ResourceType = source.ResourceType.ToString(); 120 } 139 121 } 122 #endregion // ResourceGroup 123 } 140 124 } -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.csproj
r4802 r5335 64 64 </ItemGroup> 65 65 <ItemGroup> 66 <Content Include=" ClientService.svc" />66 <Content Include="HeuristicLabServicesDemo.sln" /> 67 67 <Content Include="Web.config" /> 68 68 <Content Include="Web.Debug.config"> … … 74 74 </ItemGroup> 75 75 <ItemGroup> 76 <Compile Include=" ClientService.cs" />76 <Compile Include="AuthenticationService.cs" /> 77 77 <Compile Include="Convert.cs" /> 78 <Compile Include="ClientService.svc.cs"> 79 <DependentUpon>ClientService.svc</DependentUpon> 80 </Compile> 81 <Compile Include="Interfaces\IClientService.cs" /> 78 <Compile Include="Interfaces\IAuthenticationService.cs" /> 82 79 <Compile Include="Properties\AssemblyInfo.cs" /> 83 80 </ItemGroup> -
branches/ClientManagement/HeuristicLab.Services.Authentication/Test/Program.cs
r4958 r5335 1 1 using System; 2 using System.Text; 2 3 using System.Collections.Generic; 3 4 using System.Linq; 4 using System.Text; 5 5 6 using HeuristicLab.Services.Authentication; 7 using HL = HeuristicLab.Services.Authentication; 6 8 using DA = HeuristicLab.Services.Authentication.DataAccess; 7 9 using DT = HeuristicLab.Services.Authentication.DataTransfer; 8 9 namespace Test 10 { 11 class Program 12 { 13 static void Main(string[] args) 14 { 15 16 //DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(@"Data Source=.\SQL2008;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=True"); 17 DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(); 18 19 //if (dc.DatabaseExists()) 20 //{ 21 // Console.WriteLine("DB exsits"); 22 // dc.DeleteDatabase(); 23 // dc.SubmitChanges(); 24 // Console.WriteLine("DB deleted"); 25 //} 26 //Console.WriteLine("DB create"); 27 //dc.CreateDatabase(); 28 //dc.SubmitChanges(); 29 //Console.WriteLine("Finished"); 30 31 ClientService cs = new ClientService(); 32 33 DT.Client c = new DT.Client(); 34 35 c.Id = Guid.NewGuid(); 36 c.Name = "Eagle-Eye"; 37 c.Description = "Development-PC"; 38 c.IPAdress = "192.168.0.1"; 39 40 //c.ResourceType = "Client"; 41 DT.ResourceGroup r = new DT.ResourceGroup(); 42 r.Name = "test"; 43 44 r.Id = cs.AddResourceGroup(r); 45 46 c.ResourceGroup = r.Id; 47 c.Id = cs.AddClient(c); 48 49 //ResourceResourceGroup rrg = new ResourceResourceGroup(); 50 //rrg.ResourceGroup = r; 51 //rrg.Client = c; 52 53 54 //dc.GetTable<Resource>().InsertOnSubmit(r); 55 //dc.GetTable<Resource>().InsertOnSubmit(c); 56 57 //dc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrg); 58 59 //dc.SubmitChanges(); 60 61 62 // cs.GetClients(); 63 64 //cs.DeleteClient(c); 65 cs.DeleteResourceGroup(r); 66 67 68 } 10 using System.Data; 11 using System.Data.Common; 12 using System.Data.Linq; 13 using System.Collections; 14 15 namespace Test { 16 class Program { 17 static void Main(string[] args) { 18 19 //// //DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(@"Data Source=.\SQL2008;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=True"); 20 //// DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(); 21 22 //// if (dc.DatabaseExists()) { 23 //// Console.WriteLine("DB exsits"); 24 //// dc.DeleteDatabase(); 25 //// dc.SubmitChanges(); 26 //// Console.WriteLine("DB deleted"); 27 //// } 28 //// Console.WriteLine("DB create"); 29 //// dc.CreateDatabase(); 30 //// dc.SubmitChanges(); 31 //// Console.WriteLine("Finished"); 32 33 //// AuthenticationService cs = new AuthenticationService(); 34 35 //// DT.Client c = new DT.Client(); 36 37 //// c.Id = Guid.NewGuid(); 38 //// c.Name = "Eagle-Eye"; 39 //// c.Description = "Development-PC"; 40 //// c.IPAdress = "192.168.0.1"; 41 42 //// //c.ResourceType = "Client"; 43 //// DT.ResourceGroup r = new DT.ResourceGroup(); 44 //// r.Name = "test"; 45 46 //// //r.Id = cs.AddResourceGroup(r); 47 48 //// //c.ResourceGroup = r.Id; 49 //// //c.Id = cs.AddClient(c); 50 51 //// //ResourceResourceGroup rrg = new ResourceResourceGroup(); 52 //// //rrg.ResourceGroup = r; 53 //// //rrg.Client = c; 54 55 56 //// //dc.GetTable<Resource>().InsertOnSubmit(r); 57 //// //dc.GetTable<Resource>().InsertOnSubmit(c); 58 59 //// //dc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrg); 60 61 //// //dc.SubmitChanges(); 62 63 64 ////// cs.GetClients(); 65 66 //// //cs.DeleteClient(c); 67 ////cs.DeleteResourceGroup(r); 68 //Guid groupID1 = Guid.NewGuid(); 69 //string groupName1 = "groupName1"; 70 //Guid groupID2 = Guid.NewGuid(); 71 //string groupName2 = "groupName2"; 72 //Guid groupID3 = Guid.NewGuid(); 73 //string groupName3 = "groupName3"; 74 75 //Guid clientID1 = Guid.NewGuid(); 76 //string clientName1 = "clientName1"; 77 //Guid clientID2 = Guid.NewGuid(); 78 //string clientName2 = "clientName2"; 79 80 //DA.ClientManagmentDataContext dc = null; 81 82 //DT.Client cl1 = null; 83 //DT.Client cl2 = null; 84 //DT.Client cl3 = null; 85 86 //DT.ResourceGroup rg1 = null; 87 //DT.ResourceGroup rg2 = null; 88 //DT.ResourceGroup rg3 = null; 89 90 //DA.ResourceResourceGroup rrg1 = null; 91 //DA.ResourceResourceGroup rrg2 = null; 92 //DA.ResourceResourceGroup rrg3 = null; 93 94 //dc = new DA.ClientManagmentDataContext(); 95 //if (dc.DatabaseExists()) { 96 // //dc.DeleteDatabase(); 97 // dc.ExecuteCommand("delete from ResourceResourceGroup"); 98 // dc.ExecuteCommand("delete from Resource"); 99 // dc.SubmitChanges(); 100 //} 101 //else { 102 // dc.CreateDatabase(); 103 // dc.SubmitChanges(); 104 //} 105 106 107 //// create groups 108 //rg1 = new DT.ResourceGroup(); 109 //rg1.Name = groupName1; 110 //rg1.Id = groupID1; 111 //rg1.Description = "descr rg1"; 112 //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg1)); 113 114 //rg2 = new DT.ResourceGroup(); 115 //rg2.Name = groupName2; 116 //rg2.Id = groupID2; 117 118 //IList<Guid> rgList = new List<Guid>(); 119 //rgList.Add(rg1.Id); 120 //rg2.ResourceGroup = rgList; 121 122 //rg2.Description = "descrrg2"; 123 //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg2)); 124 125 //rg3 = new DT.ResourceGroup(); 126 //rg3.Name = groupName3; 127 //rg3.Id = groupID3; 128 //rg3.Description = "descrrg3"; 129 //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg3)); 130 131 //// create clients 132 //cl1 = new DT.Client(); 133 //cl1.Name = clientName1; 134 //cl1.Id = clientID1; 135 136 //IList<Guid> rgList1 = new List<Guid>(); 137 //rgList.Add(groupID1); 138 //cl1.ResourceGroup = rgList1; 139 140 //cl1.Description = "Test-PC-1"; 141 //cl1.IPAdress = "192.168.0.10"; 142 //cl1.NumberOfProcessors = "2"; 143 //cl1.NumberOfThreads = "4"; 144 //cl1.OperatingSystem = "WINXP"; 145 //cl1.MemorySize = "2048"; 146 //cl1.ProcessorType = "AMD"; 147 //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(cl1)); 148 149 //cl2 = new DT.Client(); 150 //cl2.Name = clientName2; 151 //cl2.Id = clientID2; 152 153 //IList<Guid> rgList2 = new List<Guid>(); 154 //rgList.Add(groupID2); 155 //cl2.ResourceGroup = rgList2; 156 157 //cl2.Description = "Test-PC-2"; 158 //cl2.IPAdress = "192.168.0.20"; 159 //cl2.NumberOfProcessors = "4"; 160 //cl2.NumberOfThreads = "4"; 161 //cl2.OperatingSystem = "Vista"; 162 //cl2.MemorySize = "4096"; 163 //cl2.ProcessorType = "Intel"; 164 //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(cl2)); 165 166 //// ResourceResourceGroups 167 //rrg1 = new DA.ResourceResourceGroup(); 168 //rrg1.ResourceId = cl1.Id; 169 //rrg1.ResourceGroupId = rg1.Id; 170 //dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg1); 171 172 //rrg2 = new DA.ResourceResourceGroup(); 173 //rrg2.ResourceId = cl2.Id; 174 //rrg2.ResourceGroupId = rg2.Id; 175 //dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg2); 176 177 //rrg3 = new DA.ResourceResourceGroup(); 178 //rrg3.ResourceId = rg1.Id; 179 //rrg3.ResourceGroupId = rg3.Id; 180 //dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg3); 181 182 //dc.SubmitChanges(); 183 184 185 // AuthenticationService cs = new AuthenticationService(); 186 187 // DA.Client client = dc.Resources.OfType<DA.Client>().First(x => x.Id == cl1.Id); 188 // DT.Client modClient = HeuristicLab.Services.Authentication.Convert.ToDto(client); 189 190 // //cl1.Id ; 191 // //cl1.ResourceType ; 192 // modClient.Name = "clientName1_modified"; 193 194 //// IList<Guid> rgList = new List<Guid>(); 195 //// rgList.Add(groupID3); 196 197 // //cl1.ResourceGroup = rgList; 198 199 // modClient.Description = "Test-PC-1_modifiet"; 200 // modClient.IPAdress = "192.168.0.11"; 201 // modClient.NumberOfProcessors = "4"; 202 // modClient.NumberOfThreads = "2"; 203 // modClient.OperatingSystem = "Vista"; 204 // modClient.MemorySize = "2196"; 205 // modClient.ProcessorType = "Intel"; 206 207 // cs.UpdateClient(modClient); 208 69 209 } 210 } 70 211 } -
branches/ClientManagement/HeuristicLab.Services.Authentication/TestWebService/TestWebService.csproj
r4958 r5335 39 39 <RequiredTargetFramework>3.5</RequiredTargetFramework> 40 40 </Reference> 41 <Reference Include="System.Data" /> 42 <Reference Include="System.Data.Linq" /> 41 43 </ItemGroup> 42 44 <ItemGroup> … … 50 52 </ItemGroup> 51 53 <ItemGroup> 54 <ProjectReference Include="..\HeuristicLab.Services.Authentication.DataAccess\HeuristicLab.Services.Authentication.DataAccess.csproj"> 55 <Project>{AC7C2117-034E-4301-8A43-C869930D404E}</Project> 56 <Name>HeuristicLab.Services.Authentication.DataAccess</Name> 57 </ProjectReference> 58 <ProjectReference Include="..\HeuristicLab.Services.Authentication.DataTransfer\HeuristicLab.Services.Authentication.DataTransfer.csproj"> 59 <Project>{73E5113E-A293-4384-8B16-3CE38F2CFDC9}</Project> 60 <Name>HeuristicLab.Services.Authentication.DataTransfer</Name> 61 </ProjectReference> 52 62 <ProjectReference Include="..\HeuristicLab.Services.Authentication\HeuristicLab.Services.Authentication.csproj"> 53 63 <Project>{ED8DC6E8-57C6-49E0-8CDF-25703AC52350}</Project> -
branches/ClientManagement/HeuristicLab.Services.Authentication/TestWebService/TestWebServiec.cs
r5004 r5335 68 68 } 69 69 70 class ResourceEqualityComparer : IEqualityComparer<DT.Resource> { 71 public bool Equals(DT.Resource rg1, DT.Resource rg2) { 72 return ( 73 rg1.Name == rg2.Name && 74 rg1.Id == rg2.Id 75 ); 76 } 77 78 public int GetHashCode(DT.Resource obj) { 79 throw new NotImplementedException(); 80 } 81 } 82 70 83 private bool CompareClients(DT.Client c1, DT.Client c2) { 71 84 return ( 72 85 c1.Name == c2.Name && 73 86 c1.Id == c2.Id && 74 //c1.ResourceType == c2.ResourceType &&87 c1.ResourceType == c2.ResourceType && 75 88 c1.Description == c2.Description && 76 89 c1.IPAdress == c2.IPAdress && … … 91 104 } 92 105 106 private bool CompareResources(DT.Resource r1, DT.Resource r2) { 107 return ( 108 r1.Name == r2.Name && 109 r1.Id == r2.Id 110 ); 111 } 112 93 113 private static int GetNumberOfEntries(string sqlCommand) { 94 114 DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(); … … 117 137 public DA.ResourceResourceGroup rrg2 = null; 118 138 public DA.ResourceResourceGroup rrg3 = null; 139 public DA.ResourceResourceGroup rrg4 = null; 140 public DA.ResourceResourceGroup rrg5 = null; 119 141 #endregion 120 142 121 143 #region Additional test attributes 122 144 // … … 142 164 143 165 [TestInitialize()] 144 public void Init() { 166 public void Init() { 145 167 146 168 dc = new DA.ClientManagmentDataContext(); … … 156 178 } 157 179 158 180 159 181 // create groups 160 182 rg1 = new DT.ResourceGroup(); 161 183 rg1.Name = groupName1; 162 rg1.Id = groupID1; 184 rg1.Id = groupID1; 163 185 rg1.Description = "descr rg1"; 164 186 dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg1)); … … 167 189 rg2.Name = groupName2; 168 190 rg2.Id = groupID2; 169 rg2.ResourceGroup = rg1.Id; 191 192 IList<Guid> rgList = new List<Guid>(); 193 rgList.Add(rg1.Id); 194 rg2.ResourceGroup = rgList; 195 170 196 rg2.Description = "descrrg2"; 171 197 dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg2)); … … 181 207 cl1.Name = clientName1; 182 208 cl1.Id = clientID1; 183 cl1.ResourceGroup = groupID1; 209 210 IList<Guid> rgList1 = new List<Guid>(); 211 rgList.Add(groupID1); 212 cl1.ResourceGroup = rgList1; 213 184 214 cl1.Description = "Test-PC-1"; 185 215 cl1.IPAdress = "192.168.0.10"; … … 194 224 cl2.Name = clientName2; 195 225 cl2.Id = clientID2; 196 cl2.ResourceGroup = groupID2; 226 227 IList<Guid> rgList2 = new List<Guid>(); 228 rgList.Add(groupID2); 229 cl2.ResourceGroup = rgList2; 230 197 231 cl2.Description = "Test-PC-2"; 198 232 cl2.IPAdress = "192.168.0.20"; … … 210 244 dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg1); 211 245 246 // ResourceResourceGroups 247 rrg5 = new DA.ResourceResourceGroup(); 248 rrg5.ResourceId = cl1.Id; 249 rrg5.ResourceGroupId = rg2.Id; 250 dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg5); 251 212 252 DA.ResourceResourceGroup rrg2 = new DA.ResourceResourceGroup(); 213 253 rrg2.ResourceId = cl2.Id; … … 215 255 dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg2); 216 256 217 DA.ResourceResourceGroup rrg3 = new DA.ResourceResourceGroup(); 218 rrg3.ResourceId = rg1.Id; 219 rrg3.ResourceGroupId = rg3.Id; 220 dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg3); 257 //DA.ResourceResourceGroup rrg3 = new DA.ResourceResourceGroup(); 258 //rrg3.ResourceId = rg3.Id; 259 //rrg3.ResourceGroupId = rg1.Id; 260 //dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg3); 261 262 rrg4 = new DA.ResourceResourceGroup(); 263 rrg4.ResourceId = rg2.Id; 264 rrg4.ResourceGroupId = rg1.Id; 265 dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg4); 221 266 222 267 dc.SubmitChanges(); … … 225 270 [TestCleanup()] 226 271 public void CleanUp() { 227 dc = new DA.ClientManagmentDataContext();228 if (dc.DatabaseExists()) {229 //dc.DeleteDatabase();230 dc.ExecuteCommand("delete from ResourceResourceGroup");231 dc.ExecuteCommand("delete from Resource");232 dc.SubmitChanges();233 }234 else {235 dc.CreateDatabase();236 dc.SubmitChanges();237 }238 } 239 240 #region TestMethods 272 //dc = new DA.ClientManagmentDataContext(); 273 //if (dc.DatabaseExists()) { 274 // //dc.DeleteDatabase(); 275 // dc.ExecuteCommand("delete from ResourceResourceGroup"); 276 // dc.ExecuteCommand("delete from Resource"); 277 // dc.SubmitChanges(); 278 //} 279 //else { 280 // dc.CreateDatabase(); 281 // dc.SubmitChanges(); 282 //} 283 } 284 285 #region TestMethods 241 286 242 287 #region TestGroup … … 247 292 [TestMethod] 248 293 public void TestAddResourceGroup() { 249 ClientService cs = new ClientService();294 AuthenticationService cs = new AuthenticationService(); 250 295 251 296 DT.ResourceGroup rg4 = new DT.ResourceGroup(); … … 265 310 266 311 /// <summary> 267 /// TODO 312 268 313 /// </summary> 269 314 [TestMethod] 270 315 public void TestUpdateResourceGroup() { 316 AuthenticationService cs = new AuthenticationService(); 317 318 DA.ResourceGroup group = dc.Resources.OfType<DA.ResourceGroup>().First(x => x.Id == rg1.Id); 319 DT.ResourceGroup modGroup = HeuristicLab.Services.Authentication.Convert.ToDto(group); 320 321 322 modGroup.Name = "clientName1_modified"; 323 324 IList<Guid> rgList = new List<Guid>(); 325 rgList.Add(groupID3); 326 modGroup.ResourceGroup = rgList; 327 modGroup.Description = "Test-group_modifiet"; 328 329 cs.UpdateResourceGroup(modGroup); 271 330 } 272 331 … … 276 335 [TestMethod] 277 336 public void TestGetResourceGroup() { 278 ClientService cs = new ClientService();337 AuthenticationService cs = new AuthenticationService(); 279 338 DT.ResourceGroup rg = cs.GetResourceGroup(groupID1); 280 339 Assert.AreEqual(rg.Id, groupID1); … … 287 346 [TestMethod] 288 347 public void TestGetResourceGroups() { 289 ClientService cs = new ClientService();348 AuthenticationService cs = new AuthenticationService(); 290 349 IEnumerable<DT.ResourceGroup> groups = cs.GetResourceGroups(); 291 350 Assert.AreEqual(3, groups.Count<DT.ResourceGroup>()); … … 298 357 299 358 /// <summary> 300 /// Delete existing ResourceGroup whi sch is no parent group359 /// Delete existing ResourceGroup which is no parent group 301 360 /// </summary> 302 361 [TestMethod] 303 362 public void TestDeleteResourceGroup1() { 304 ClientService cs = new ClientService();363 AuthenticationService cs = new AuthenticationService(); 305 364 306 365 int cntPrev = GetNumberOfEntries(sqlCountGroups); 307 Assert.IsTrue(cs.DeleteResourceGroup(rg2));366 cs.DeleteResourceGroup(rg2); 308 367 int cntNew = GetNumberOfEntries(sqlCountGroups); 309 368 Assert.AreEqual(cntPrev, (cntNew + 1)); … … 311 370 312 371 /// <summary> 313 /// try to delete existing ResourceGroup w hisch is parent group372 /// try to delete existing ResourceGroup wich is parent group 314 373 /// </summary> 315 374 [TestMethod] 316 375 public void TestDeleteResourceGroup2() { 317 ClientService cs = new ClientService(); 318 376 AuthenticationService cs = new AuthenticationService(); 319 377 int cntPrev = GetNumberOfEntries(sqlCountGroups); 320 Assert.IsFalse(cs.DeleteResourceGroup(rg1));378 cs.DeleteResourceGroup(rg1); 321 379 int cntNew = GetNumberOfEntries(sqlCountGroups); 322 380 Assert.AreEqual(cntPrev, cntNew); … … 332 390 [TestMethod] 333 391 public void TestAddClient1() { 334 ClientService cs = new ClientService();392 AuthenticationService cs = new AuthenticationService(); 335 393 336 394 DT.Client cl3 = new DT.Client(); 337 395 cl3.Name = "clientName3"; 338 cl3.ResourceGroup = groupID3; 396 397 IList<Guid> rgList = new List<Guid>(); 398 rgList.Add(groupID3); 399 cl3.ResourceGroup = rgList; 400 339 401 cl3.Description = "Test-PC-3"; 340 402 cl3.IPAdress = "192.168.0.30"; … … 347 409 int cntPrev = GetNumberOfEntries(sqlCountClients); 348 410 cl3.Id = cs.AddClient(cl3); 349 Assert.AreNotEqual(Guid.Empty, cl3.Id); 411 Assert.AreNotEqual(Guid.Empty, cl3.Id); 350 412 int cntNew = GetNumberOfEntries(sqlCountClients); 351 413 Assert.AreEqual(cntPrev, (cntNew - 1)); … … 360 422 [TestMethod] 361 423 public void TestAddClient2() { 362 ClientService cs = new ClientService();424 AuthenticationService cs = new AuthenticationService(); 363 425 364 426 DT.Client cl3 = new DT.Client(); 365 427 cl3.Name = "clientNamexxxx"; 366 cl3.ResourceGroup = Guid.NewGuid(); 428 429 IList<Guid> rgList = new List<Guid>(); 430 rgList.Add(Guid.NewGuid()); 431 cl3.ResourceGroup = rgList; 367 432 368 433 int cntPrev = GetNumberOfEntries(sqlCountClients); … … 370 435 Assert.AreEqual(Guid.Empty, cl3.Id); 371 436 int cntNew = GetNumberOfEntries(sqlCountClients); 372 Assert.AreEqual(cntPrev, cntNew); 437 Assert.AreEqual(cntPrev, cntNew); 373 438 } 374 439 … … 378 443 [TestMethod] 379 444 public void TestGetClient1() { 380 ClientService cs = new ClientService();445 AuthenticationService cs = new AuthenticationService(); 381 446 DT.Client cl = cs.GetClient(clientID1); 382 447 Assert.AreEqual(cl.Id, clientID1); … … 392 457 //[TestMethod] 393 458 //public void TestGetClient2() { 394 // ClientService cs = new ClientService();459 // AuthenticationService cs = new AuthenticationService(); 395 460 // DT.Client cl = cs.GetClient(Guid.NewGuid()); 396 461 // Assert.IsNull(cl); … … 402 467 //[TestMethod] 403 468 //public void TestGetClient3() { 404 // ClientService cs = new ClientService();469 // AuthenticationService cs = new AuthenticationService(); 405 470 // DT.Client cl = cs.GetClient(Guid.Empty); 406 471 // Assert.IsNull(cl); … … 416 481 [TestMethod] 417 482 public void TestDeleteClient1() { 418 ClientService cs = new ClientService();483 AuthenticationService cs = new AuthenticationService(); 419 484 420 485 int cntPrev = GetNumberOfEntries(sqlCountClients); 421 Assert.IsTrue(cs.DeleteClient(cl1));486 cs.DeleteClient(cl1); 422 487 int cntNew = GetNumberOfEntries(sqlCountClients); 423 488 Assert.AreEqual(cntPrev, (cntNew + 1)); 424 489 } 425 490 426 /// <summary> 427 /// try to delete not existing client 428 /// </summary> 429 [TestMethod] 430 public void TestDeleteClient2() { 431 ClientService cs = new ClientService(); 432 DT.Client cl3 = new DT.Client(); 433 cl3.Name = "clientName3"; 434 cl3.ResourceGroup = groupID3; 435 cl3.Description = "Test-PC-3"; 436 cl3.IPAdress = "192.168.0.30"; 437 cl3.NumberOfProcessors = "2"; 438 cl3.NumberOfThreads = "2"; 439 cl3.OperatingSystem = "Vista"; 440 cl3.MemorySize = "4096"; 441 cl3.ProcessorType = "Intel"; 442 443 int cntPrev = GetNumberOfEntries(sqlCountClients); 444 Assert.IsFalse(cs.DeleteClient(cl3)); 445 int cntNew = GetNumberOfEntries(sqlCountClients); 446 Assert.AreEqual(cntPrev, cntNew); 447 } 491 ///// <summary> 492 ///// try to delete not existing client 493 ///// </summary> 494 //[TestMethod] 495 //public void TestDeleteClient2() { 496 // AuthenticationService cs = new AuthenticationService(); 497 // DT.Client cl3 = new DT.Client(); 498 // cl3.Name = "clientName3"; 499 500 // IList<Guid> rgList = new List<Guid>(); 501 // rgList.Add(groupID3); 502 // cl3.ResourceGroup = rgList; 503 504 // cl3.Description = "Test-PC-3"; 505 // cl3.IPAdress = "192.168.0.30"; 506 // cl3.NumberOfProcessors = "2"; 507 // cl3.NumberOfThreads = "2"; 508 // cl3.OperatingSystem = "Vista"; 509 // cl3.MemorySize = "4096"; 510 // cl3.ProcessorType = "Intel"; 511 512 // int cntPrev = GetNumberOfEntries(sqlCountClients); 513 // cs.DeleteClient(cl3); 514 // int cntNew = GetNumberOfEntries(sqlCountClients); 515 // Assert.AreEqual(cntPrev, cntNew); 516 //} 448 517 449 518 /// <summary> … … 452 521 [TestMethod] 453 522 public void TestGetClients() { 454 ClientService cs = new ClientService();523 AuthenticationService cs = new AuthenticationService(); 455 524 IEnumerable<DT.Client> clients = cs.GetClients(); 456 525 Assert.AreEqual(2, clients.Count<DT.Client>()); … … 466 535 [TestMethod] 467 536 public void TestUpdateClient1() { 468 ClientService cs = new ClientService(); 469 DT.Client cl1 = new DT.Client(); 470 cl1.Name = "clientName1_modified"; 471 cl1.ResourceGroup = groupID3; 472 cl1.Description = "Test-PC-1_modifiet"; 473 cl1.IPAdress = "192.168.0.11"; 474 cl1.NumberOfProcessors = "4"; 475 cl1.NumberOfThreads = "2"; 476 cl1.OperatingSystem = "Vista"; 477 cl1.MemorySize = "2096"; 478 cl1.ProcessorType = "Intel"; 479 480 int cntPrev = GetNumberOfEntries(sqlCountClients); 481 Assert.IsTrue(cs.UpdateClient(cl1)); 482 int cntNew = GetNumberOfEntries(sqlCountClients); 483 Assert.AreEqual(cntPrev, cntNew); 537 AuthenticationService cs = new AuthenticationService(); 484 538 485 539 DA.Client client = dc.Resources.OfType<DA.Client>().First(x => x.Id == cl1.Id); 486 Assert.IsTrue(CompareClients(HL.Convert.ToDto(client), cl1)); 487 } 488 489 /// <summary> 490 /// try to update not existing client 491 /// </summary> 492 [TestMethod] 493 public void TestUpdateClient2() { 494 ClientService cs = new ClientService(); 495 DT.Client cl3 = new DT.Client(); 496 cl3.Id = Guid.NewGuid(); 497 cl3.Name = "clientName3"; 498 cl3.ResourceGroup = groupID3; 499 cl3.Description = "Test-PC-3"; 500 cl3.IPAdress = "192.168.0.30"; 501 cl3.NumberOfProcessors = "2"; 502 cl3.NumberOfThreads = "2"; 503 cl3.OperatingSystem = "Vista"; 504 cl3.MemorySize = "4096"; 505 cl3.ProcessorType = "Intel"; 506 507 int cntPrev = GetNumberOfEntries(sqlCountClients); 508 Assert.IsFalse(cs.UpdateClient(cl3)); 509 int cntNew = GetNumberOfEntries(sqlCountClients); 510 Assert.AreEqual(cntPrev, cntNew); 511 512 DA.Client client = dc.Resources.OfType<DA.Client>().First(x => x.Id == cl3.Id); 513 Assert.IsNull(client); 514 } 540 DT.Client modClient = HeuristicLab.Services.Authentication.Convert.ToDto(client); 541 542 //cl1.Id ; 543 //cl1.ResourceType ; 544 modClient.Name = "clientName1_modified"; 545 546 IList<Guid> rgList = new List<Guid>(); 547 rgList.Add(groupID3); 548 modClient.ResourceGroup = rgList; 549 550 modClient.Description = "Test-PC-1_modifiet"; 551 modClient.IPAdress = "192.168.0.11"; 552 modClient.NumberOfProcessors = "4"; 553 modClient.NumberOfThreads = "2"; 554 modClient.OperatingSystem = "Vista"; 555 modClient.MemorySize = "2196"; 556 modClient.ProcessorType = "Intel"; 557 558 cs.UpdateClient(modClient); 559 560 //DA.Client client1 = dc.Resources.OfType<DA.Client>().First(x => x.Id == cl1.Id); 561 //Assert.IsTrue(CompareClients(HL.Convert.ToDto(client1), modClient)); 562 } 563 564 ///// <summary> 565 ///// try to update not existing client 566 ///// </summary> 567 //[TestMethod] 568 //public void TestUpdateClient2() { 569 // AuthenticationService cs = new AuthenticationService(); 570 // DT.Client cl3 = new DT.Client(); 571 // cl3.Id = Guid.NewGuid(); 572 // cl3.Name = "clientName3"; 573 574 // IList<Guid> rgList = new List<Guid>(); 575 // rgList.Add(groupID3); 576 // cl3.ResourceGroup = rgList; 577 578 // cl3.Description = "Test-PC-3"; 579 // cl3.IPAdress = "192.168.0.30"; 580 // cl3.NumberOfProcessors = "2"; 581 // cl3.NumberOfThreads = "2"; 582 // cl3.OperatingSystem = "Vista"; 583 // cl3.MemorySize = "4096"; 584 // cl3.ProcessorType = "Intel"; 585 586 // int cntPrev = GetNumberOfEntries(sqlCountClients); 587 // //Assert.IsFalse(cs.UpdateClient(cl3)); 588 // int cntNew = GetNumberOfEntries(sqlCountClients); 589 // Assert.AreEqual(cntPrev, cntNew); 590 591 // DA.Client client = dc.Resources.OfType<DA.Client>().First(x => x.Id == cl3.Id); 592 // Assert.IsNull(client); 593 //} 515 594 516 595 #endregion 517 596 597 /// <summary> 598 /// get Members 599 /// </summary> 600 [TestMethod] 601 public void TestGetMembers() { 602 AuthenticationService cs = new AuthenticationService(); 603 IEnumerable<DT.Resource> members = cs.GetMembers(rg1.Id); 604 Assert.AreEqual(2, members.Count()); 605 } 606 607 /// <summary> 608 /// get ResourceGroupsOf 609 /// </summary> 610 [TestMethod] 611 public void TestGetResourceGroupsOf() { 612 AuthenticationService cs = new AuthenticationService(); 613 IEnumerable<DT.Resource> resGroups = cs.GetResourceGroupsOf(cl1.Id); 614 Assert.AreEqual(2, resGroups.Count()); 615 } 616 617 /// <summary> 618 /// get Members 619 /// </summary> 620 [TestMethod] 621 public void TestGetRootResources() { 622 AuthenticationService cs = new AuthenticationService(); 623 IEnumerable<DT.Resource> rootResourceList = cs.GetRootResources(); 624 Assert.AreEqual(2, rootResourceList.Count()); 625 } 626 518 627 #endregion //Testmethods 519 628 }
Note: See TracChangeset
for help on using the changeset viewer.