From 7ebf580875fc00ff9a594167d2ff56547eaaf48c Mon Sep 17 00:00:00 2001 From: Grzegorz Mrukwa Date: Tue, 8 Aug 2017 23:14:32 +0200 Subject: [PATCH 01/97] Add dataset model --- src/Spectre.Database/App.config | 17 +++++ src/Spectre.Database/Entities/Dataset.cs | 21 +++++++ .../Migrations/Configuration.cs | 12 ++++ .../Properties/AssemblyInfo.cs | 36 +++++++++++ src/Spectre.Database/Spectre.Database.csproj | 60 ++++++++++++++++++ src/Spectre.Database/Utils/Context.cs | 10 +++ src/Spectre.Database/packages.config | 4 ++ src/Spectre.sln | 62 +++++++++++++++++++ 8 files changed, 222 insertions(+) create mode 100644 src/Spectre.Database/App.config create mode 100644 src/Spectre.Database/Entities/Dataset.cs create mode 100644 src/Spectre.Database/Migrations/Configuration.cs create mode 100644 src/Spectre.Database/Properties/AssemblyInfo.cs create mode 100644 src/Spectre.Database/Spectre.Database.csproj create mode 100644 src/Spectre.Database/Utils/Context.cs create mode 100644 src/Spectre.Database/packages.config diff --git a/src/Spectre.Database/App.config b/src/Spectre.Database/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/src/Spectre.Database/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Spectre.Database/Entities/Dataset.cs b/src/Spectre.Database/Entities/Dataset.cs new file mode 100644 index 0000000..a061465 --- /dev/null +++ b/src/Spectre.Database/Entities/Dataset.cs @@ -0,0 +1,21 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Spectre.Database.Entities +{ + public class Dataset + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ItemId { get; set; } + [Index] + public string hash { get; set; } + [Index] + public string FriendlyName { get; set; } + public string Owner { get; set; } + public DateTime UploadTime { get; set; } + public string Description { get; set; } + public string Location { get; set; } + } +} diff --git a/src/Spectre.Database/Migrations/Configuration.cs b/src/Spectre.Database/Migrations/Configuration.cs new file mode 100644 index 0000000..7a2c611 --- /dev/null +++ b/src/Spectre.Database/Migrations/Configuration.cs @@ -0,0 +1,12 @@ +using System.Data.Entity.Migrations; + +namespace Spectre.Database.Migrations +{ + internal sealed class Configuration : DbMigrationsConfiguration + { + public Configuration() + { + AutomaticMigrationsEnabled = true; + } + } +} diff --git a/src/Spectre.Database/Properties/AssemblyInfo.cs b/src/Spectre.Database/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1942239 --- /dev/null +++ b/src/Spectre.Database/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Spectre.Database")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Spectre.Database")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b5b60f79-653c-4e41-9721-06c478ce9e7c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Spectre.Database/Spectre.Database.csproj b/src/Spectre.Database/Spectre.Database.csproj new file mode 100644 index 0000000..1a2cf00 --- /dev/null +++ b/src/Spectre.Database/Spectre.Database.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C} + Library + Properties + Spectre.Database + Spectre.Database + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Spectre.Database/Utils/Context.cs b/src/Spectre.Database/Utils/Context.cs new file mode 100644 index 0000000..efc4d2d --- /dev/null +++ b/src/Spectre.Database/Utils/Context.cs @@ -0,0 +1,10 @@ +using System.Data.Entity; +using Spectre.Database.Entities; + +namespace Spectre.Database.Utils +{ + public class Context : DbContext + { + public DbSet Datasets { get; set; } + } +} diff --git a/src/Spectre.Database/packages.config b/src/Spectre.Database/packages.config new file mode 100644 index 0000000..4409173 --- /dev/null +++ b/src/Spectre.Database/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Spectre.sln b/src/Spectre.sln index 0682266..d62d401 100644 --- a/src/Spectre.sln +++ b/src/Spectre.sln @@ -89,116 +89,178 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution CSharpCodingConvention.ruleset = CSharpCodingConvention.ruleset EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectre.Database", "Spectre.Database\Spectre.Database.csproj", "{B5B60F79-653C-4E41-9721-06C478CE9E7C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|Any CPU.ActiveCfg = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.ActiveCfg = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.Build.0 = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.Deploy.0 = Debug|x64 + {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|Any CPU.ActiveCfg = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.ActiveCfg = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.Build.0 = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.Deploy.0 = Release|x64 + {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|Any CPU.ActiveCfg = Debug|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|x64.ActiveCfg = Debug|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|x64.Build.0 = Debug|x64 + {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|Any CPU.ActiveCfg = Release|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|x64.ActiveCfg = Release|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|x64.Build.0 = Release|x64 + {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|Any CPU.ActiveCfg = Debug|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|x64.ActiveCfg = Debug|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|x64.Build.0 = Debug|x64 + {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|Any CPU.ActiveCfg = Release|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|x64.ActiveCfg = Release|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|x64.Build.0 = Release|x64 + {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|Any CPU.ActiveCfg = Debug|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|x64.ActiveCfg = Debug|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|x64.Build.0 = Debug|x64 + {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|Any CPU.ActiveCfg = Release|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|x64.ActiveCfg = Release|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|x64.Build.0 = Release|x64 + {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|Any CPU.ActiveCfg = Debug|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|x64.ActiveCfg = Debug|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|x64.Build.0 = Debug|x64 + {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|Any CPU.ActiveCfg = Release|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|x64.ActiveCfg = Release|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|x64.Build.0 = Release|x64 + {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|Any CPU.ActiveCfg = Debug|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|x64.ActiveCfg = Debug|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|x64.Build.0 = Debug|x64 + {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|Any CPU.ActiveCfg = Release|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|x64.ActiveCfg = Release|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|x64.Build.0 = Release|x64 + {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|Any CPU.ActiveCfg = Debug|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|x64.ActiveCfg = Debug|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|x64.Build.0 = Debug|x64 + {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|Any CPU.ActiveCfg = Release|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|x64.ActiveCfg = Release|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|x64.Build.0 = Release|x64 + {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|Any CPU.ActiveCfg = Debug|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|x64.ActiveCfg = Debug|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|x64.Build.0 = Debug|x64 + {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|Any CPU.ActiveCfg = Release|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|x64.ActiveCfg = Release|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|x64.Build.0 = Release|x64 + {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|Any CPU.ActiveCfg = Debug|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|x64.ActiveCfg = Debug|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|x64.Build.0 = Debug|x64 + {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|Any CPU.ActiveCfg = Release|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|x64.ActiveCfg = Release|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|x64.Build.0 = Release|x64 + {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|Any CPU.ActiveCfg = Debug|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|x64.ActiveCfg = Debug|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|x64.Build.0 = Debug|x64 + {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|Any CPU.ActiveCfg = Release|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|x64.ActiveCfg = Release|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|x64.Build.0 = Release|x64 + {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|Any CPU.ActiveCfg = Debug|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|x64.ActiveCfg = Debug|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|x64.Build.0 = Debug|x64 + {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|Any CPU.ActiveCfg = Release|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|x64.ActiveCfg = Release|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|x64.Build.0 = Release|x64 + {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|Any CPU.ActiveCfg = Debug|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|x64.ActiveCfg = Debug|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|x64.Build.0 = Debug|x64 + {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|Any CPU.ActiveCfg = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.ActiveCfg = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.Build.0 = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.Deploy.0 = Release|x64 + {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|Any CPU.ActiveCfg = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.ActiveCfg = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.Build.0 = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.Deploy.0 = Debug|x64 + {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|Any CPU.ActiveCfg = Release|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|x64.ActiveCfg = Release|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|x64.Build.0 = Release|x64 + {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|Any CPU.ActiveCfg = Debug|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|x64.ActiveCfg = Debug|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|x64.Build.0 = Debug|x64 + {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|Any CPU.ActiveCfg = Release|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|x64.ActiveCfg = Release|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|x64.Build.0 = Release|x64 + {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|Any CPU.ActiveCfg = Debug|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|x64.ActiveCfg = Debug|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|x64.Build.0 = Debug|x64 + {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|Any CPU.ActiveCfg = Release|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|x64.ActiveCfg = Release|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|x64.Build.0 = Release|x64 + {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|Any CPU.ActiveCfg = Debug|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|x64.ActiveCfg = Debug|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|x64.Build.0 = Debug|x64 + {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|Any CPU.ActiveCfg = Release|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|x64.ActiveCfg = Release|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|x64.Build.0 = Release|x64 + {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|Any CPU.ActiveCfg = Debug|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|x64.ActiveCfg = Debug|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|x64.Build.0 = Debug|x64 + {9786751A-6AE1-48D3-938D-4129D0399667}.Release|Any CPU.ActiveCfg = Release|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Release|x64.ActiveCfg = Release|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Release|x64.Build.0 = Release|x64 + {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|Any CPU.ActiveCfg = Debug|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|x64.ActiveCfg = Debug|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|x64.Build.0 = Debug|x64 + {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|Any CPU.ActiveCfg = Release|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|x64.ActiveCfg = Release|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|x64.Build.0 = Release|x64 + {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|Any CPU.ActiveCfg = Debug|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|x64.ActiveCfg = Debug|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|x64.Build.0 = Debug|x64 + {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|Any CPU.ActiveCfg = Release|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|x64.ActiveCfg = Release|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|x64.Build.0 = Release|x64 + {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|Any CPU.ActiveCfg = Debug|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|x64.ActiveCfg = Debug|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|x64.Build.0 = Debug|x64 + {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|Any CPU.ActiveCfg = Release|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|x64.ActiveCfg = Release|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|x64.Build.0 = Release|x64 + {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|Any CPU.ActiveCfg = Debug|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|x64.ActiveCfg = Debug|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|x64.Build.0 = Debug|x64 + {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|Any CPU.ActiveCfg = Release|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|x64.ActiveCfg = Release|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|x64.Build.0 = Release|x64 + {7417BF00-028B-4797-B58A-6058CA338493}.Debug|Any CPU.ActiveCfg = Debug|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Debug|x64.ActiveCfg = Debug|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Debug|x64.Build.0 = Debug|x64 + {7417BF00-028B-4797-B58A-6058CA338493}.Release|Any CPU.ActiveCfg = Release|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Release|x64.ActiveCfg = Release|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Release|x64.Build.0 = Release|x64 + {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|Any CPU.ActiveCfg = Debug|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|x64.ActiveCfg = Debug|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|x64.Build.0 = Debug|x64 + {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|Any CPU.ActiveCfg = Release|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|x64.ActiveCfg = Release|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|x64.Build.0 = Release|x64 + {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|Any CPU.ActiveCfg = Debug|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|x64.ActiveCfg = Debug|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|x64.Build.0 = Debug|x64 + {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|Any CPU.ActiveCfg = Release|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|x64.ActiveCfg = Release|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|x64.Build.0 = Release|x64 + {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|Any CPU.ActiveCfg = Debug|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|x64.ActiveCfg = Debug|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|x64.Build.0 = Debug|x64 + {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|Any CPU.ActiveCfg = Release|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|x64.ActiveCfg = Release|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|x64.Build.0 = Release|x64 + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.ActiveCfg = Debug|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.Build.0 = Debug|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|Any CPU.Build.0 = Release|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.ActiveCfg = Release|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 6697dcd6efcdd2678789935281b4f00b559701a8 Mon Sep 17 00:00:00 2001 From: Grzegorz Mrukwa Date: Tue, 8 Aug 2017 23:27:13 +0200 Subject: [PATCH 02/97] Add StyleCop, remove AnyCPU target, add docstrings --- src/Spectre.Database/Entities/Dataset.cs | 74 ++++++++++++++++++- .../Migrations/Configuration.cs | 28 ++++++- .../Properties/AssemblyInfo.cs | 3 +- src/Spectre.Database/Spectre.Database.csproj | 27 ++++--- src/Spectre.Database/Utils/Context.cs | 31 +++++++- src/Spectre.Database/packages.config | 1 + src/Spectre.sln | 64 +--------------- 7 files changed, 153 insertions(+), 75 deletions(-) diff --git a/src/Spectre.Database/Entities/Dataset.cs b/src/Spectre.Database/Entities/Dataset.cs index a061465..1c38855 100644 --- a/src/Spectre.Database/Entities/Dataset.cs +++ b/src/Spectre.Database/Entities/Dataset.cs @@ -1,21 +1,91 @@ -using System; +/* + * Dataset.cs + * Database model of dataset metadata + * + Copyright 2017 Roman Lisak + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Spectre.Database.Entities { + /// + /// Abstraction of dataset metadata needed to load a dataset + /// public class Dataset { + /// + /// Gets or sets the item identifier. + /// + /// + /// The item identifier. + /// [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int ItemId { get; set; } + + /// + /// Gets or sets the hash. + /// + /// + /// The hash. + /// [Index] - public string hash { get; set; } + public string Hash { get; set; } + + /// + /// Gets or sets the friendly name. + /// + /// + /// The friendly name. + /// [Index] public string FriendlyName { get; set; } + + /// + /// Gets or sets the owner. + /// + /// + /// The owner. + /// public string Owner { get; set; } + + /// + /// Gets or sets the upload time. + /// + /// + /// The upload time. + /// public DateTime UploadTime { get; set; } + + /// + /// Gets or sets the description. + /// + /// + /// The description. + /// public string Description { get; set; } + + /// + /// Gets or sets the location on the disk. + /// + /// + /// The location on the disk. + /// public string Location { get; set; } } } diff --git a/src/Spectre.Database/Migrations/Configuration.cs b/src/Spectre.Database/Migrations/Configuration.cs index 7a2c611..af5622d 100644 --- a/src/Spectre.Database/Migrations/Configuration.cs +++ b/src/Spectre.Database/Migrations/Configuration.cs @@ -1,9 +1,35 @@ -using System.Data.Entity.Migrations; +/* + * Configuration.cs + * Configuration which creates automatic migrations + * + Copyright 2017 Roman Lisak + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Data.Entity.Migrations; namespace Spectre.Database.Migrations { + /// + /// Configuration of dataset migrations. + /// + /// internal sealed class Configuration : DbMigrationsConfiguration { + /// + /// Initializes a new instance of the class. + /// public Configuration() { AutomaticMigrationsEnabled = true; diff --git a/src/Spectre.Database/Properties/AssemblyInfo.cs b/src/Spectre.Database/Properties/AssemblyInfo.cs index 1942239..c0d03d4 100644 --- a/src/Spectre.Database/Properties/AssemblyInfo.cs +++ b/src/Spectre.Database/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Reflection; +// +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/Spectre.Database/Spectre.Database.csproj b/src/Spectre.Database/Spectre.Database.csproj index 1a2cf00..32bf6dc 100644 --- a/src/Spectre.Database/Spectre.Database.csproj +++ b/src/Spectre.Database/Spectre.Database.csproj @@ -12,22 +12,25 @@ v4.5.2 512 - + true - full - false - bin\Debug\ + bin\x64\Debug\ DEBUG;TRACE + full + x64 prompt - 4 + ..\CSharpCodingConvention.ruleset + bin\x64\Debug\Spectre.Database.xml - - pdbonly - true - bin\Release\ + + bin\x64\Release\ TRACE + true + pdbonly + x64 prompt - 4 + ..\CSharpCodingConvention.ruleset + bin\x64\Release\Spectre.Database.xml @@ -56,5 +59,9 @@ + + + + \ No newline at end of file diff --git a/src/Spectre.Database/Utils/Context.cs b/src/Spectre.Database/Utils/Context.cs index efc4d2d..0ac12cf 100644 --- a/src/Spectre.Database/Utils/Context.cs +++ b/src/Spectre.Database/Utils/Context.cs @@ -1,10 +1,39 @@ -using System.Data.Entity; +/* + * Context.cs + * Databse context for connections with database. + * + Copyright 2017 Roman Lisak + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Data.Entity; using Spectre.Database.Entities; namespace Spectre.Database.Utils { + /// + /// Context for database access. + /// + /// public class Context : DbContext { + /// + /// Gets or sets the datasets. + /// + /// + /// The datasets. + /// public DbSet Datasets { get; set; } } } diff --git a/src/Spectre.Database/packages.config b/src/Spectre.Database/packages.config index 4409173..d5ce45d 100644 --- a/src/Spectre.Database/packages.config +++ b/src/Spectre.Database/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/src/Spectre.sln b/src/Spectre.sln index d62d401..a014762 100644 --- a/src/Spectre.sln +++ b/src/Spectre.sln @@ -93,174 +93,118 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectre.Database", "Spectre EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 - Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|Any CPU.ActiveCfg = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.ActiveCfg = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.Build.0 = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.Deploy.0 = Debug|x64 - {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|Any CPU.ActiveCfg = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.ActiveCfg = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.Build.0 = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.Deploy.0 = Release|x64 - {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|Any CPU.ActiveCfg = Debug|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|x64.ActiveCfg = Debug|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|x64.Build.0 = Debug|x64 - {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|Any CPU.ActiveCfg = Release|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|x64.ActiveCfg = Release|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|x64.Build.0 = Release|x64 - {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|Any CPU.ActiveCfg = Debug|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|x64.ActiveCfg = Debug|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|x64.Build.0 = Debug|x64 - {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|Any CPU.ActiveCfg = Release|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|x64.ActiveCfg = Release|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|x64.Build.0 = Release|x64 - {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|Any CPU.ActiveCfg = Debug|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|x64.ActiveCfg = Debug|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|x64.Build.0 = Debug|x64 - {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|Any CPU.ActiveCfg = Release|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|x64.ActiveCfg = Release|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|x64.Build.0 = Release|x64 - {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|Any CPU.ActiveCfg = Debug|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|x64.ActiveCfg = Debug|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|x64.Build.0 = Debug|x64 - {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|Any CPU.ActiveCfg = Release|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|x64.ActiveCfg = Release|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|x64.Build.0 = Release|x64 - {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|Any CPU.ActiveCfg = Debug|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|x64.ActiveCfg = Debug|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|x64.Build.0 = Debug|x64 - {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|Any CPU.ActiveCfg = Release|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|x64.ActiveCfg = Release|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|x64.Build.0 = Release|x64 - {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|Any CPU.ActiveCfg = Debug|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|x64.ActiveCfg = Debug|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|x64.Build.0 = Debug|x64 - {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|Any CPU.ActiveCfg = Release|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|x64.ActiveCfg = Release|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|x64.Build.0 = Release|x64 - {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|Any CPU.ActiveCfg = Debug|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|x64.ActiveCfg = Debug|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|x64.Build.0 = Debug|x64 - {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|Any CPU.ActiveCfg = Release|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|x64.ActiveCfg = Release|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|x64.Build.0 = Release|x64 - {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|Any CPU.ActiveCfg = Debug|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|x64.ActiveCfg = Debug|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|x64.Build.0 = Debug|x64 - {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|Any CPU.ActiveCfg = Release|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|x64.ActiveCfg = Release|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|x64.Build.0 = Release|x64 - {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|Any CPU.ActiveCfg = Debug|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|x64.ActiveCfg = Debug|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|x64.Build.0 = Debug|x64 - {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|Any CPU.ActiveCfg = Release|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|x64.ActiveCfg = Release|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|x64.Build.0 = Release|x64 - {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|Any CPU.ActiveCfg = Debug|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|x64.ActiveCfg = Debug|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|x64.Build.0 = Debug|x64 - {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|Any CPU.ActiveCfg = Release|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|x64.ActiveCfg = Release|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|x64.Build.0 = Release|x64 - {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|Any CPU.ActiveCfg = Debug|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|x64.ActiveCfg = Debug|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|x64.Build.0 = Debug|x64 - {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|Any CPU.ActiveCfg = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.ActiveCfg = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.Build.0 = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.Deploy.0 = Release|x64 - {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|Any CPU.ActiveCfg = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.ActiveCfg = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.Build.0 = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.Deploy.0 = Debug|x64 - {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|Any CPU.ActiveCfg = Release|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|x64.ActiveCfg = Release|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|x64.Build.0 = Release|x64 - {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|Any CPU.ActiveCfg = Debug|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|x64.ActiveCfg = Debug|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|x64.Build.0 = Debug|x64 - {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|Any CPU.ActiveCfg = Release|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|x64.ActiveCfg = Release|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|x64.Build.0 = Release|x64 - {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|Any CPU.ActiveCfg = Debug|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|x64.ActiveCfg = Debug|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|x64.Build.0 = Debug|x64 - {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|Any CPU.ActiveCfg = Release|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|x64.ActiveCfg = Release|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|x64.Build.0 = Release|x64 - {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|Any CPU.ActiveCfg = Debug|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|x64.ActiveCfg = Debug|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|x64.Build.0 = Debug|x64 - {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|Any CPU.ActiveCfg = Release|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|x64.ActiveCfg = Release|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|x64.Build.0 = Release|x64 - {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|Any CPU.ActiveCfg = Debug|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|x64.ActiveCfg = Debug|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|x64.Build.0 = Debug|x64 - {9786751A-6AE1-48D3-938D-4129D0399667}.Release|Any CPU.ActiveCfg = Release|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Release|x64.ActiveCfg = Release|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Release|x64.Build.0 = Release|x64 - {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|Any CPU.ActiveCfg = Debug|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|x64.ActiveCfg = Debug|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|x64.Build.0 = Debug|x64 - {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|Any CPU.ActiveCfg = Release|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|x64.ActiveCfg = Release|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|x64.Build.0 = Release|x64 - {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|Any CPU.ActiveCfg = Debug|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|x64.ActiveCfg = Debug|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|x64.Build.0 = Debug|x64 - {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|Any CPU.ActiveCfg = Release|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|x64.ActiveCfg = Release|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|x64.Build.0 = Release|x64 - {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|Any CPU.ActiveCfg = Debug|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|x64.ActiveCfg = Debug|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|x64.Build.0 = Debug|x64 - {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|Any CPU.ActiveCfg = Release|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|x64.ActiveCfg = Release|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|x64.Build.0 = Release|x64 - {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|Any CPU.ActiveCfg = Debug|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|x64.ActiveCfg = Debug|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|x64.Build.0 = Debug|x64 - {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|Any CPU.ActiveCfg = Release|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|x64.ActiveCfg = Release|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|x64.Build.0 = Release|x64 - {7417BF00-028B-4797-B58A-6058CA338493}.Debug|Any CPU.ActiveCfg = Debug|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Debug|x64.ActiveCfg = Debug|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Debug|x64.Build.0 = Debug|x64 - {7417BF00-028B-4797-B58A-6058CA338493}.Release|Any CPU.ActiveCfg = Release|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Release|x64.ActiveCfg = Release|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Release|x64.Build.0 = Release|x64 - {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|Any CPU.ActiveCfg = Debug|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|x64.ActiveCfg = Debug|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|x64.Build.0 = Debug|x64 - {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|Any CPU.ActiveCfg = Release|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|x64.ActiveCfg = Release|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|x64.Build.0 = Release|x64 - {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|Any CPU.ActiveCfg = Debug|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|x64.ActiveCfg = Debug|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|x64.Build.0 = Debug|x64 - {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|Any CPU.ActiveCfg = Release|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|x64.ActiveCfg = Release|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|x64.Build.0 = Release|x64 - {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|Any CPU.ActiveCfg = Debug|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|x64.ActiveCfg = Debug|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|x64.Build.0 = Debug|x64 - {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|Any CPU.ActiveCfg = Release|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|x64.ActiveCfg = Release|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|x64.Build.0 = Release|x64 - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.ActiveCfg = Debug|Any CPU - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.Build.0 = Debug|Any CPU - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|Any CPU.Build.0 = Release|Any CPU - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.ActiveCfg = Release|Any CPU - {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.Build.0 = Release|Any CPU + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.ActiveCfg = Debug|x64 + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.Build.0 = Debug|x64 + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.ActiveCfg = Release|x64 + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 18d39e89a02fef36664e4270c34f082dd31c1b72 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 11 Aug 2017 01:40:41 +0200 Subject: [PATCH 03/97] Methods[C for translation --- src/Spectre.Database/Entities/Dataset.cs | 2 +- src/Spectre.Database/Spectre.Database.csproj | 1 + src/Spectre.Database/Utils/PathFinder.cs | 84 ++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/Spectre.Database/Utils/PathFinder.cs diff --git a/src/Spectre.Database/Entities/Dataset.cs b/src/Spectre.Database/Entities/Dataset.cs index 1c38855..d9a3aa3 100644 --- a/src/Spectre.Database/Entities/Dataset.cs +++ b/src/Spectre.Database/Entities/Dataset.cs @@ -51,7 +51,7 @@ public class Dataset /// Gets or sets the friendly name. /// /// - /// The friendly name. + /// The friendly name /// [Index] public string FriendlyName { get; set; } diff --git a/src/Spectre.Database/Spectre.Database.csproj b/src/Spectre.Database/Spectre.Database.csproj index 32bf6dc..49efd23 100644 --- a/src/Spectre.Database/Spectre.Database.csproj +++ b/src/Spectre.Database/Spectre.Database.csproj @@ -54,6 +54,7 @@ + diff --git a/src/Spectre.Database/Utils/PathFinder.cs b/src/Spectre.Database/Utils/PathFinder.cs new file mode 100644 index 0000000..5605657 --- /dev/null +++ b/src/Spectre.Database/Utils/PathFinder.cs @@ -0,0 +1,84 @@ +/* + * PathFinder.cs + * Class for translating hash and friendly name to name of the file. + * + Copyright 2017 Roman Lisak + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Spectre.Database.Entities; + +namespace Spectre.Database.Utils +{ + /// + /// Class for finding the path of chosen property. + /// + public class PathFinder + { + /// + /// The temporary... + /// + private static string _hash; + + /// + /// The friendlyname... + /// + private static string _friendlyname; + + /// + /// Returns for hash. + /// + /// The hash. + /// + /// Returns location having hash. + /// + public string ReturnForHash(string hash) + { + using (var context = new Context()) + { + var location = context.Datasets + .Where(b => b.Hash == hash) + .FirstOrDefault(); + _hash = location.ToString(); + } + + return _hash; + } + + /// + /// Returns the name of friendly name. + /// + /// The hash. + /// + /// Returns location having friendly name. + /// + public string ReturnForFriendlyName(string hash) + { + using (var context = new Context()) + { + var location = context.Datasets + .Where(b => b.Hash == hash) + .FirstOrDefault(); + _friendlyname = location.ToString(); + } + + return _friendlyname; + } + } +} From dc5287d95b7a91f37af5ccc84d0934cfe3e3e1ba Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 11 Aug 2017 14:33:48 +0200 Subject: [PATCH 04/97] Fixed queries --- src/Spectre.Database/Utils/PathFinder.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Spectre.Database/Utils/PathFinder.cs b/src/Spectre.Database/Utils/PathFinder.cs index 5605657..f2826a6 100644 --- a/src/Spectre.Database/Utils/PathFinder.cs +++ b/src/Spectre.Database/Utils/PathFinder.cs @@ -34,12 +34,12 @@ public class PathFinder /// /// The temporary... /// - private static string _hash; + private static string _locationfromhash; /// /// The friendlyname... /// - private static string _friendlyname; + private static string __locationfromfriendlyname; /// /// Returns for hash. @@ -55,30 +55,30 @@ public string ReturnForHash(string hash) var location = context.Datasets .Where(b => b.Hash == hash) .FirstOrDefault(); - _hash = location.ToString(); + _locationfromhash = location.Location.ToString(); } - return _hash; + return _locationfromhash; } /// /// Returns the name of friendly name. /// - /// The hash. + /// The friendlyname. /// /// Returns location having friendly name. /// - public string ReturnForFriendlyName(string hash) + public string ReturnForFriendlyName(string friendlyname) { using (var context = new Context()) { var location = context.Datasets - .Where(b => b.Hash == hash) + .Where(b => b.Hash == friendlyname) .FirstOrDefault(); - _friendlyname = location.ToString(); + __locationfromfriendlyname = location.Location.ToString(); } - return _friendlyname; + return __locationfromfriendlyname; } } } From 31ff8e7fd960ef1388cb0b09255d1e2d7eac239a Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Aug 2017 15:27:49 +0200 Subject: [PATCH 05/97] added tests for queries --- .gitattributes | 138 ++++++++++-------- ...deDom.Providers.DotNetCompilerPlatform.dll | Bin 0 -> 29344 bytes ...deDom.Providers.DotNetCompilerPlatform.xml | 40 +++++ src/Spectre.Database.Tests/App.config | 17 +++ .../Properties/AssemblyInfo.cs | 20 +++ src/Spectre.Database.Tests/QueryTests.cs | 69 +++++++++ .../Spectre.Database.Tests.csproj | 97 ++++++++++++ src/Spectre.Database.Tests/packages.config | 11 ++ src/Spectre.Database/Entities/Dataset.cs | 2 - src/Spectre.Database/Utils/Context.cs | 2 +- src/Spectre.Database/Utils/PathFinder.cs | 48 ++++-- src/Spectre.sln | 66 ++++++++- 12 files changed, 428 insertions(+), 82 deletions(-) create mode 100644 src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll create mode 100644 src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml create mode 100644 src/Spectre.Database.Tests/App.config create mode 100644 src/Spectre.Database.Tests/Properties/AssemblyInfo.cs create mode 100644 src/Spectre.Database.Tests/QueryTests.cs create mode 100644 src/Spectre.Database.Tests/Spectre.Database.Tests.csproj create mode 100644 src/Spectre.Database.Tests/packages.config diff --git a/.gitattributes b/.gitattributes index 1ff0c42..3d18c38 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,63 +1,77 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto +using System; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Mocks; -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain +[TestFixture] +public class PersonServiceTest +{ +// The dynamic mock proxy that we will use to implement IPersonRepository +private DynamicMock personRepositoryMock; +// Set up some testing data +private Person onePerson = new Person("1", "Wendy", "Whiner"); +private Person secondPerson = new Person("2", "Aaron", "Adams"); +private List peopleList; +[SetUp] +public void TestInit() +{ +peopleList = new List(); +peopleList.Add(onePerson); +peopleList.Add(secondPerson); +// Construct a Mock Object of the IPersonRepository Interface +personRepositoryMock = new DynamicMock(typeof (IPersonRepository)); +} +[Test] +public void TestGetAllPeople() +{ +// Tell that mock object when the "GetPeople" method is +// called to return a predefined list of people +personRepositoryMock.ExpectAndReturn("GetPeople", peopleList); +// Construct a Person service with the Mock IPersonRepository +PersonService service = new PersonService( +(IPersonRepository) personRepositoryMock.MockInstance); +// Call methods and assert tests +Assert.AreEqual(2, service.GetAllPeople().Count); +} +[Test] +public void TestGetAllPeopleSorted() +{ +// Tell that mock object when the "GetPeople" method is called to +// return a predefined list of people +personRepositoryMock.ExpectAndReturn("GetPeople", peopleList); +PersonService service = new PersonService( +(IPersonRepository) personRepositoryMock.MockInstance); +// This method really has "business logic" in it - the sorting of people +List people = service.GetAllPeopleSorted(); +Assert.IsNotNull(people); +Assert.AreEqual(2, people.Count); +// Make sure the first person returned is the correct one +Person p = people[0]; +Assert.AreEqual("Adams", p.LastName); +} +[Test] +public void TestGetSinglePersonWithValidId() +{ +// Tell that mock object when the "GetPerson" method is called to +// return a predefined Person +personRepositoryMock.ExpectAndReturn("GetPersonById", onePerson, "1"); +PersonService service = new PersonService( +(IPersonRepository) personRepositoryMock.MockInstance); +Person p = service.GetPerson("1"); +Assert.IsNotNull(p); +Assert.AreEqual(p.Id, "1"); +} +[Test] +public void TestGetSinglePersonWithInalidId() +{ +// Tell that mock object when the "GetPersonById" is called with a null +// value to throw an ArgumentException +personRepositoryMock.ExpectAndThrow("GetPersonById", +new ArgumentException("Invalid person id."), null); +PersonService service = new PersonService( +(IPersonRepository) personRepositoryMock.MockInstance); +// The only way to get null is if the underlying IPersonRepository +// threw an ArgumentException +Assert.IsNull(service.GetPerson(null)); +} +} \ No newline at end of file diff --git a/src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll b/src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll new file mode 100644 index 0000000000000000000000000000000000000000..4d638b3dfee44afaec33e17070f2b58bc1983a29 GIT binary patch literal 29344 zcmeHv33yXQ_xIeJhPv|Ge-2eZJ@Wsy%nknKNh3 zIdkUBa&H-O^Swkt2vOqq@?}D{;Yok`GWhpFBdT>BU(%7SA$t?HafA0Jl#h3MOm&i2 zBiU+AcAMKRdQFuMlT`0EIo+oIL(5FHVwEE`JY3twC%UwdkindS)Z%HvZzFyQiDYG7)|(Op3h2-4_ys*7j)Ps}W>Z%Bf9unSQWAa^K<-dl zXe8tyb%OtAG$Cu+0$D>y7#`&=LfZT5{+XvKpgQB$03R6CF4gOp;st(u2mtDstC8S>v%8IX3zv74L z#uF8pl|#tBOhQ5!wH1__{H|}MU9a?X-^7n!OVEB0y8he7k8bwt8h2oIA^+y2W4VV; zKfC;VecsM4B@=!-UD>U7o8E8rI=|?(=*@=G@l`i& z&W|=ky#3jHaow?(&Po>|{&?xM=J|J5Y+rKe!;d@f9Ns?n;=~vGjlSo1zTv~F+crNo zbL5QYXKr10+tiV~xeXy&UNN0RaPZ3M@Pjgu5Tiv!EKnF!y&@%4!n4j34bD51!1Mu( zSHvtt$Z=XBTG=9)F*SrlqeV$NqAf(}J+Ww`<)>2V3c(WxOhlMy1+g7qB57w)kaF;% zp*||~+McX|o|Nj8aQ>12d4dO#r43b^Av6i93ug3`WJc5qVMoFgBKp>fCV($Ai5#dr z=|Id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KK$7>FPGnG9bPgbWyaB{(eITX?YiuN!Mmpn^Om{4JzZLI<88fOj+*`H zw!Lecd9$UN@6tLNg0-1%1CpM_-=hE8dVl?Q4?)p)t0lHoYlSs5fT%gdULd+u)(G~V z03T#o@+|nh`I^`pv}yICmUYe(X(!amH+PyVI%a&H85}FPRHd;pI82o-10H;2fBRqb<&R4-Lo#2|2Reowi zBH90ZPDoVZ@`QuMPaXLD?ak-REt8jLb(_;E=SXb(*B{&Z$n>{|uKuv>zWd%UO-dd# R>cZO(bt#&6ppouJ{|}6;XNCX( literal 0 HcmV?d00001 diff --git a/src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml b/src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml new file mode 100644 index 0000000..1a49351 --- /dev/null +++ b/src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml @@ -0,0 +1,40 @@ + + + + Microsoft.CodeDom.Providers.DotNetCompilerPlatform + + + + + Provides access to instances of the .NET Compiler Platform C# code generator and code compiler. + + + + + Default Constructor + + + + + Gets an instance of the .NET Compiler Platform C# code compiler. + + An instance of the .NET Compiler Platform C# code compiler + + + + Provides access to instances of the .NET Compiler Platform VB code generator and code compiler. + + + + + Default Constructor + + + + + Gets an instance of the .NET Compiler Platform VB code compiler. + + An instance of the .NET Compiler Platform VB code compiler + + + diff --git a/src/Spectre.Database.Tests/App.config b/src/Spectre.Database.Tests/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/src/Spectre.Database.Tests/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Spectre.Database.Tests/Properties/AssemblyInfo.cs b/src/Spectre.Database.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0891f9e --- /dev/null +++ b/src/Spectre.Database.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Spectre.Database.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Spectre.Database.Tests")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("2d5ad568-f2ee-4b8c-af81-2c46eb45b0ed")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Spectre.Database.Tests/QueryTests.cs b/src/Spectre.Database.Tests/QueryTests.cs new file mode 100644 index 0000000..c13fd9a --- /dev/null +++ b/src/Spectre.Database.Tests/QueryTests.cs @@ -0,0 +1,69 @@ +/* + * QueryTests.cs + * Testing queries for translation + * + Copyright 2017 Roman Lisak + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Spectre.Database.Entities; +using Spectre.Database.Utils; +using System.Data.Entity; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; +using NUnit.Mocks; +using Moq; + + +namespace Spectre.Database.Tests +{ + [TestFixture] + public class QueryTests + { + + [Test] + public void QueryTest() + { + var data = new List + { + new Dataset { FriendlyName = "Jacek1", Hash = "1", Location = "path1"}, + new Dataset { FriendlyName = "Bajer2", Hash = "2", Location = "path2"}, + new Dataset { FriendlyName = "Janusz3", Hash = "3", Location = "path3"}, + }.AsQueryable(); + + var mockSet = new Mock>(); + mockSet.As>().Setup(m => m.Provider).Returns(data.Provider); + mockSet.As>().Setup(m => m.Expression).Returns(data.Expression); + mockSet.As>().Setup(m => m.ElementType).Returns(data.ElementType); + mockSet.As>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); + + var mockContext = new Mock(); + mockContext.Setup(c => c.Datasets).Returns(mockSet.Object); + + + var service = new PathFinder(mockContext.Object); + var dataset1 = service.ReturnForHash("1"); + var dataset2 = service.ReturnForFriendlyName("Bajer2"); + + NUnit.Framework.Assert.AreEqual("path1", dataset1); + NUnit.Framework.Assert.AreEqual("path2", dataset2); + } + } +} + + diff --git a/src/Spectre.Database.Tests/Spectre.Database.Tests.csproj b/src/Spectre.Database.Tests/Spectre.Database.Tests.csproj new file mode 100644 index 0000000..62998e5 --- /dev/null +++ b/src/Spectre.Database.Tests/Spectre.Database.Tests.csproj @@ -0,0 +1,97 @@ + + + + + + Debug + AnyCPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED} + Library + Properties + Spectre.Database.Tests + Spectre.Database.Tests + v4.5.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + ..\CSharpCodingConvention.ruleset + x64 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + ..\packages\Moq.4.7.99\lib\net45\Moq.dll + + + ..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll + + + ..\packages\NUnit.Mocks.2.6.4\lib\nunit.mocks.dll + + + + + + + + + + + + + + + + {b5b60f79-653c-4e41-9721-06c478ce9e7c} + Spectre.Database + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/Spectre.Database.Tests/packages.config b/src/Spectre.Database.Tests/packages.config new file mode 100644 index 0000000..04baf8f --- /dev/null +++ b/src/Spectre.Database.Tests/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Spectre.Database/Entities/Dataset.cs b/src/Spectre.Database/Entities/Dataset.cs index d9a3aa3..f7baf02 100644 --- a/src/Spectre.Database/Entities/Dataset.cs +++ b/src/Spectre.Database/Entities/Dataset.cs @@ -44,7 +44,6 @@ public class Dataset /// /// The hash. /// - [Index] public string Hash { get; set; } /// @@ -53,7 +52,6 @@ public class Dataset /// /// The friendly name /// - [Index] public string FriendlyName { get; set; } /// diff --git a/src/Spectre.Database/Utils/Context.cs b/src/Spectre.Database/Utils/Context.cs index 0ac12cf..fd32609 100644 --- a/src/Spectre.Database/Utils/Context.cs +++ b/src/Spectre.Database/Utils/Context.cs @@ -34,6 +34,6 @@ public class Context : DbContext /// /// The datasets. /// - public DbSet Datasets { get; set; } + public virtual DbSet Datasets { get; set; } } } diff --git a/src/Spectre.Database/Utils/PathFinder.cs b/src/Spectre.Database/Utils/PathFinder.cs index f2826a6..06a27da 100644 --- a/src/Spectre.Database/Utils/PathFinder.cs +++ b/src/Spectre.Database/Utils/PathFinder.cs @@ -19,6 +19,7 @@ limitations under the License. using System; using System.Collections.Generic; +using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -32,14 +33,33 @@ namespace Spectre.Database.Utils public class PathFinder { /// - /// The temporary... + /// Variable for returning location from hash /// private static string _locationfromhash; /// - /// The friendlyname... + /// Variable for returning location from friendly name /// - private static string __locationfromfriendlyname; + private static string _locationfromfriendlyname; + + /// + /// The location + /// + private Dataset _path = new Dataset(); + + /// + /// The context description + /// + private Context _context; + + /// + /// Initializes a new instance of the class. + /// + /// The context. + public PathFinder(Context context) + { + _context = context; + } /// /// Returns for hash. @@ -50,15 +70,13 @@ public class PathFinder /// public string ReturnForHash(string hash) { - using (var context = new Context()) - { - var location = context.Datasets + _path = _context.Datasets .Where(b => b.Hash == hash) .FirstOrDefault(); - _locationfromhash = location.Location.ToString(); - } - return _locationfromhash; + PathFinder._locationfromhash = _path.Location.ToString(); + + return PathFinder._locationfromhash; } /// @@ -70,15 +88,13 @@ public string ReturnForHash(string hash) /// public string ReturnForFriendlyName(string friendlyname) { - using (var context = new Context()) - { - var location = context.Datasets - .Where(b => b.Hash == friendlyname) + _path = _context.Datasets + .Where(b => b.FriendlyName == friendlyname) .FirstOrDefault(); - __locationfromfriendlyname = location.Location.ToString(); - } - return __locationfromfriendlyname; + PathFinder._locationfromfriendlyname = _path.Location.ToString(); + + return PathFinder._locationfromfriendlyname; } } } diff --git a/src/Spectre.sln b/src/Spectre.sln index a014762..f902421 100644 --- a/src/Spectre.sln +++ b/src/Spectre.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.12 +VisualStudioVersion = 15.0.26228.10 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectre", "Spectre\Spectre.csproj", "{0E4F265B-8702-4D70-AB70-AA566D7A2E40}" EndProject @@ -91,120 +91,184 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectre.Database", "Spectre.Database\Spectre.Database.csproj", "{B5B60F79-653C-4E41-9721-06C478CE9E7C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectre.Database.Tests", "Spectre.Database.Tests\Spectre.Database.Tests.csproj", "{2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|Any CPU.ActiveCfg = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.ActiveCfg = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.Build.0 = Debug|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Debug|x64.Deploy.0 = Debug|x64 + {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|Any CPU.ActiveCfg = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.ActiveCfg = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.Build.0 = Release|x64 {0E4F265B-8702-4D70-AB70-AA566D7A2E40}.Release|x64.Deploy.0 = Release|x64 + {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|Any CPU.ActiveCfg = Debug|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|x64.ActiveCfg = Debug|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Debug|x64.Build.0 = Debug|x64 + {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|Any CPU.ActiveCfg = Release|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|x64.ActiveCfg = Release|x64 {D0AF5823-2044-48DF-8982-EB1C86855112}.Release|x64.Build.0 = Release|x64 + {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|Any CPU.ActiveCfg = Debug|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|x64.ActiveCfg = Debug|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Debug|x64.Build.0 = Debug|x64 + {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|Any CPU.ActiveCfg = Release|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|x64.ActiveCfg = Release|x64 {9A886AEC-58DB-410D-91B9-C62E157501FA}.Release|x64.Build.0 = Release|x64 + {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|Any CPU.ActiveCfg = Debug|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|x64.ActiveCfg = Debug|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Debug|x64.Build.0 = Debug|x64 + {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|Any CPU.ActiveCfg = Release|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|x64.ActiveCfg = Release|x64 {BBF6329D-7BEC-494E-9FC9-B24B12D94EA0}.Release|x64.Build.0 = Release|x64 + {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|Any CPU.ActiveCfg = Debug|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|x64.ActiveCfg = Debug|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Debug|x64.Build.0 = Debug|x64 + {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|Any CPU.ActiveCfg = Release|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|x64.ActiveCfg = Release|x64 {70C87AF7-3189-4F6C-AC85-93309CF7CFDC}.Release|x64.Build.0 = Release|x64 + {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|Any CPU.ActiveCfg = Debug|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|x64.ActiveCfg = Debug|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Debug|x64.Build.0 = Debug|x64 + {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|Any CPU.ActiveCfg = Release|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|x64.ActiveCfg = Release|x64 {01391E76-3D20-4B4B-B727-2A133B35A144}.Release|x64.Build.0 = Release|x64 + {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|Any CPU.ActiveCfg = Debug|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|x64.ActiveCfg = Debug|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Debug|x64.Build.0 = Debug|x64 + {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|Any CPU.ActiveCfg = Release|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|x64.ActiveCfg = Release|x64 {2D24F1E7-18D4-4FC0-9E4F-2F32FF27FCCE}.Release|x64.Build.0 = Release|x64 + {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|Any CPU.ActiveCfg = Debug|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|x64.ActiveCfg = Debug|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Debug|x64.Build.0 = Debug|x64 + {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|Any CPU.ActiveCfg = Release|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|x64.ActiveCfg = Release|x64 {23A97D0F-B6D9-4B67-84FE-4B52EA7D82EC}.Release|x64.Build.0 = Release|x64 + {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|Any CPU.ActiveCfg = Debug|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|x64.ActiveCfg = Debug|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Debug|x64.Build.0 = Debug|x64 + {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|Any CPU.ActiveCfg = Release|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|x64.ActiveCfg = Release|x64 {F518ED4B-ADE0-4B5C-A01B-48D9FA216E0C}.Release|x64.Build.0 = Release|x64 + {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|Any CPU.ActiveCfg = Debug|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|x64.ActiveCfg = Debug|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Debug|x64.Build.0 = Debug|x64 + {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|Any CPU.ActiveCfg = Release|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|x64.ActiveCfg = Release|x64 {287A1A8D-C029-4D47-96BC-755C91B7985D}.Release|x64.Build.0 = Release|x64 + {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|Any CPU.ActiveCfg = Debug|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|x64.ActiveCfg = Debug|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Debug|x64.Build.0 = Debug|x64 + {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|Any CPU.ActiveCfg = Release|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|x64.ActiveCfg = Release|x64 {1D79FD14-1DF4-4AED-94DF-62E595206DEF}.Release|x64.Build.0 = Release|x64 + {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|Any CPU.ActiveCfg = Debug|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|x64.ActiveCfg = Debug|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Debug|x64.Build.0 = Debug|x64 + {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|Any CPU.ActiveCfg = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.ActiveCfg = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.Build.0 = Release|x64 {7C9D29C3-E8F6-46A2-9905-B0776EB85EA3}.Release|x64.Deploy.0 = Release|x64 + {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|Any CPU.ActiveCfg = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.ActiveCfg = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.Build.0 = Debug|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Debug|x64.Deploy.0 = Debug|x64 + {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|Any CPU.ActiveCfg = Release|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|x64.ActiveCfg = Release|x64 {8463BCA2-41C7-4992-A704-7CEE66AC6E89}.Release|x64.Build.0 = Release|x64 + {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|Any CPU.ActiveCfg = Debug|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|x64.ActiveCfg = Debug|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Debug|x64.Build.0 = Debug|x64 + {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|Any CPU.ActiveCfg = Release|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|x64.ActiveCfg = Release|x64 {450F225C-4610-4B20-84AE-2ED5B4C8D7C4}.Release|x64.Build.0 = Release|x64 + {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|Any CPU.ActiveCfg = Debug|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|x64.ActiveCfg = Debug|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Debug|x64.Build.0 = Debug|x64 + {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|Any CPU.ActiveCfg = Release|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|x64.ActiveCfg = Release|x64 {1C2E181F-EAB0-46AA-B096-8BC78D7D8DB3}.Release|x64.Build.0 = Release|x64 + {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|Any CPU.ActiveCfg = Debug|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|x64.ActiveCfg = Debug|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Debug|x64.Build.0 = Debug|x64 + {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|Any CPU.ActiveCfg = Release|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|x64.ActiveCfg = Release|x64 {369BDAFF-9E57-40D0-830D-B9232F35E4F4}.Release|x64.Build.0 = Release|x64 + {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|Any CPU.ActiveCfg = Debug|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|x64.ActiveCfg = Debug|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Debug|x64.Build.0 = Debug|x64 + {9786751A-6AE1-48D3-938D-4129D0399667}.Release|Any CPU.ActiveCfg = Release|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Release|x64.ActiveCfg = Release|x64 {9786751A-6AE1-48D3-938D-4129D0399667}.Release|x64.Build.0 = Release|x64 + {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|Any CPU.ActiveCfg = Debug|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|x64.ActiveCfg = Debug|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Debug|x64.Build.0 = Debug|x64 + {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|Any CPU.ActiveCfg = Release|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|x64.ActiveCfg = Release|x64 {B7DB309D-3ED6-4771-993D-A1CF3A6436D9}.Release|x64.Build.0 = Release|x64 + {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|Any CPU.ActiveCfg = Debug|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|x64.ActiveCfg = Debug|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Debug|x64.Build.0 = Debug|x64 + {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|Any CPU.ActiveCfg = Release|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|x64.ActiveCfg = Release|x64 {E6B2EF6F-86BD-4E2C-B860-1B9F0D3B9556}.Release|x64.Build.0 = Release|x64 + {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|Any CPU.ActiveCfg = Debug|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|x64.ActiveCfg = Debug|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Debug|x64.Build.0 = Debug|x64 + {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|Any CPU.ActiveCfg = Release|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|x64.ActiveCfg = Release|x64 {2185C120-7B01-4E2E-B200-858A2D25C715}.Release|x64.Build.0 = Release|x64 + {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|Any CPU.ActiveCfg = Debug|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|x64.ActiveCfg = Debug|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Debug|x64.Build.0 = Debug|x64 + {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|Any CPU.ActiveCfg = Release|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|x64.ActiveCfg = Release|x64 {104D9A93-F6D7-4BF4-961F-7C52FEAEA77B}.Release|x64.Build.0 = Release|x64 + {7417BF00-028B-4797-B58A-6058CA338493}.Debug|Any CPU.ActiveCfg = Debug|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Debug|x64.ActiveCfg = Debug|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Debug|x64.Build.0 = Debug|x64 + {7417BF00-028B-4797-B58A-6058CA338493}.Release|Any CPU.ActiveCfg = Release|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Release|x64.ActiveCfg = Release|x64 {7417BF00-028B-4797-B58A-6058CA338493}.Release|x64.Build.0 = Release|x64 + {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|Any CPU.ActiveCfg = Debug|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|x64.ActiveCfg = Debug|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Debug|x64.Build.0 = Debug|x64 + {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|Any CPU.ActiveCfg = Release|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|x64.ActiveCfg = Release|x64 {F5FFC2E5-66F4-493A-8D77-D47128A719D9}.Release|x64.Build.0 = Release|x64 + {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|Any CPU.ActiveCfg = Debug|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|x64.ActiveCfg = Debug|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Debug|x64.Build.0 = Debug|x64 + {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|Any CPU.ActiveCfg = Release|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|x64.ActiveCfg = Release|x64 {5419AEEB-98B4-4D79-9FCA-A794200073FC}.Release|x64.Build.0 = Release|x64 + {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|Any CPU.ActiveCfg = Debug|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|x64.ActiveCfg = Debug|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Debug|x64.Build.0 = Debug|x64 + {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|Any CPU.ActiveCfg = Release|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|x64.ActiveCfg = Release|x64 {B6B8D608-32E7-4F09-B91D-EA5832D74C07}.Release|x64.Build.0 = Release|x64 + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|Any CPU.ActiveCfg = Debug|x64 {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.ActiveCfg = Debug|x64 {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Debug|x64.Build.0 = Debug|x64 + {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|Any CPU.ActiveCfg = Release|x64 {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.ActiveCfg = Release|x64 {B5B60F79-653C-4E41-9721-06C478CE9E7C}.Release|x64.Build.0 = Release|x64 + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Debug|x64.ActiveCfg = Debug|Any CPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Debug|x64.Build.0 = Debug|Any CPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Release|Any CPU.Build.0 = Release|Any CPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Release|x64.ActiveCfg = Release|Any CPU + {2D5AD568-F2EE-4B8C-AF81-2C46EB45B0ED}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 23f63d17e2dd47a59272983718d5b644c96ebafb Mon Sep 17 00:00:00 2001 From: Sebaxp95 Date: Sun, 17 Sep 2017 20:34:22 +0200 Subject: [PATCH 06/97] divik level --- src/Spectre.AngularClient/package.json | 2 +- src/Spectre.AngularClient/src/app/app.module.ts | 3 ++- .../src/app/divik-results/divik/divik.component.html | 12 +++++++++++- .../app/divik-results/divik/divik.component.spec.ts | 3 ++- .../src/app/divik-results/divik/divik.component.ts | 11 +++++++++++ .../src/app/preparations/preparations.module.ts | 6 ++++-- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/Spectre.AngularClient/package.json b/src/Spectre.AngularClient/package.json index 02ee6fc..9545246 100644 --- a/src/Spectre.AngularClient/package.json +++ b/src/Spectre.AngularClient/package.json @@ -59,7 +59,7 @@ "@angular/core": "^5.0.0-beta.0", "@angular/forms": "^5.0.0-beta.0", "@angular/http": "^5.0.0-beta.0", - "@angular/material": "^2.0.0-beta.8", + "@angular/material": "^2.0.0-beta.10", "@angular/platform-browser": "^5.0.0-beta.0", "@angular/platform-browser-dynamic": "^5.0.0-beta.0", "@angular/platform-server": "^5.0.0-beta.0", diff --git a/src/Spectre.AngularClient/src/app/app.module.ts b/src/Spectre.AngularClient/src/app/app.module.ts index b8b328f..d3f51c8 100644 --- a/src/Spectre.AngularClient/src/app/app.module.ts +++ b/src/Spectre.AngularClient/src/app/app.module.ts @@ -21,12 +21,12 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { routing } from './app.routing'; import { AppComponent } from './app.component'; import { PreparationListComponent } from './preparations/preparation-list/preparation-list.component'; -import { PreparationService } from './preparations/shared/preparation.service'; import { PreparationsModule } from './preparations/preparations.module'; import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; import { PlotlyModule } from './plotly/plotly.module'; @@ -54,6 +54,7 @@ import { DivikService } from './divik-results/shared/divik.service'; HttpModule, PlotlyModule, PreparationsModule, + BrowserAnimationsModule, routing ], bootstrap: [AppComponent] diff --git a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html index 083e770..66cfcbf 100644 --- a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html +++ b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html @@ -3,9 +3,19 @@ {{configDescription}} + + + Max value: divikConfig.Level + + - + diff --git a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.spec.ts b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.spec.ts index 905682e..cb865aa 100644 --- a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.spec.ts +++ b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.spec.ts @@ -29,6 +29,7 @@ import { PlotlyModule } from '../../plotly/plotly.module'; import { DivikComponent } from './divik.component'; import { DivikService } from '../shared/divik.service'; import { HeatmapComponent } from '../../heatmaps/heatmap/heatmap.component'; +import { MdFormFieldModule, MdInputModule, MdSliderModule } from '@angular/material'; describe('DivikComponent', () => { let component: DivikComponent; @@ -37,7 +38,7 @@ describe('DivikComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [DivikComponent, HeatmapComponent], - imports: [RouterTestingModule, PlotlyModule], + imports: [RouterTestingModule, PlotlyModule, MdFormFieldModule, MdInputModule, MdSliderModule], providers: [ MockBackend, BaseRequestOptions, diff --git a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts index 0f3076e..f155216 100644 --- a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts +++ b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts @@ -34,6 +34,7 @@ import { DivikConfig } from '../shared/divik-config'; export class DivikComponent implements OnInit { public data: any; public configDescription: string; + public divikConfig: DivikConfig; public downloadJsonHref: any; constructor( private route: ActivatedRoute, @@ -57,6 +58,7 @@ export class DivikComponent implements OnInit { }]; } buildConfigInfo(config: DivikConfig): string { + this.divikConfig = config; let description = ''; Object.keys(config).forEach((key) => { description += key + ': ' + config[key] + '\n'; @@ -65,6 +67,15 @@ export class DivikComponent implements OnInit { return description; } + changeLevel(value) { + console.log('change ' + value); + if (value > 0 && value <= this.divikConfig.Level) { + this.divikService + .get(1, 1, value) + .subscribe(heatmap => this.data = this.toHeatmapDataset(heatmap)); + } + } + generateDownloadJsonUri(config: DivikConfig) { const theJSON = JSON.stringify(config); this.downloadJsonHref = this.sanitizer.bypassSecurityTrustUrl('data:text/json;charset=UTF-8,' + encodeURIComponent(theJSON)); diff --git a/src/Spectre.AngularClient/src/app/preparations/preparations.module.ts b/src/Spectre.AngularClient/src/app/preparations/preparations.module.ts index 5ab3743..53d288b 100644 --- a/src/Spectre.AngularClient/src/app/preparations/preparations.module.ts +++ b/src/Spectre.AngularClient/src/app/preparations/preparations.module.ts @@ -21,7 +21,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; -import { MdSliderModule } from '@angular/material'; +import { MdFormFieldModule, MdInputModule, MdSliderModule} from '@angular/material'; import { PreparationRoutingModule } from './preparation-routing.module'; import { PlotlyModule } from '../plotly/plotly.module'; @@ -39,7 +39,9 @@ import { DivikComponent } from '../divik-results/divik/divik.component'; FormsModule, PreparationRoutingModule, PlotlyModule, - MdSliderModule + MdSliderModule, + MdInputModule, + MdFormFieldModule ], declarations: [ PreparationComponent, From faab1fa08ed7d60eb2ba5b458d86cb825c7f1964 Mon Sep 17 00:00:00 2001 From: Daroslaw Date: Tue, 19 Sep 2017 17:08:29 +0200 Subject: [PATCH 07/97] Obtaining datasets via DatasetLoader. --- src/Spectre/Controllers/DivikResultController.cs | 10 +++++++++- src/Spectre/Controllers/HeatmapController.cs | 9 ++++++++- src/Spectre/Controllers/SpectrumController.cs | 15 +++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/Spectre/Controllers/DivikResultController.cs b/src/Spectre/Controllers/DivikResultController.cs index 3eb74cc..b902216 100644 --- a/src/Spectre/Controllers/DivikResultController.cs +++ b/src/Spectre/Controllers/DivikResultController.cs @@ -19,6 +19,7 @@ limitations under the License. using System; using System.Collections.Generic; +using System.Configuration; using System.IO; using System.Linq; using System.Net; @@ -29,6 +30,8 @@ limitations under the License. using Spectre.Algorithms.Parameterization; using Spectre.Data.Datasets; using Spectre.Models.Msi; +using Spectre.Service.Configuration; +using Spectre.Service.Loaders; namespace Spectre.Controllers { @@ -61,7 +64,12 @@ public DivikResult Get(int id, int divikId, int level) var jsonText = File.ReadAllText("C:\\spectre_data\\expected_divik_results\\hnc1_tumor\\euclidean\\divik-result.json"); Algorithms.Results.DivikResult divikResult = JsonConvert.DeserializeObject(jsonText); - IDataset dataset = new BasicTextDataset(textFilePath: "C:\\spectre_data\\hnc1_tumor.txt"); + DatasetLoader datasetLoader = new DatasetLoader( + new DataRootConfig( + ConfigurationManager.AppSettings["LocalDataDirectory"], + ConfigurationManager.AppSettings["RemoteDataDirectory"])); + IDataset dataset = datasetLoader.GetFromName("hnc1_tumor.txt"); + var coordinates = dataset.GetRawSpacialCoordinates(is2D: true); int length = divikResult.Partition.Length; diff --git a/src/Spectre/Controllers/HeatmapController.cs b/src/Spectre/Controllers/HeatmapController.cs index 55fd30b..81c5bb6 100644 --- a/src/Spectre/Controllers/HeatmapController.cs +++ b/src/Spectre/Controllers/HeatmapController.cs @@ -14,6 +14,9 @@ You may obtain a copy of the License at limitations under the License. */ +using Spectre.Service.Configuration; +using Spectre.Service.Loaders; + namespace Spectre.Controllers { using System; @@ -52,7 +55,11 @@ public Heatmap Get(int id, int channelId, bool flag) return null; } - IDataset dataset = new BasicTextDataset(textFilePath: ConfigurationManager.AppSettings["LocalDataDirectory"] + Path.DirectorySeparatorChar + "hnc1_tumor.txt"); + DatasetLoader datasetLoader = new DatasetLoader( + new DataRootConfig( + ConfigurationManager.AppSettings["LocalDataDirectory"], + ConfigurationManager.AppSettings["RemoteDataDirectory"])); + IDataset dataset = datasetLoader.GetFromName("hnc1_tumor.txt"); var mz = dataset.GetRawMzValue(channelId); var intensities = dataset.GetRawIntensityRow(channelId); diff --git a/src/Spectre/Controllers/SpectrumController.cs b/src/Spectre/Controllers/SpectrumController.cs index adbeefd..ad152bf 100644 --- a/src/Spectre/Controllers/SpectrumController.cs +++ b/src/Spectre/Controllers/SpectrumController.cs @@ -14,6 +14,9 @@ You may obtain a copy of the License at limitations under the License. */ +using Spectre.Service.Configuration; +using Spectre.Service.Loaders; + namespace Spectre.Controllers { using System; @@ -45,7 +48,11 @@ public Spectrum Get(int id, int spectrumId) throw new HttpResponseException(HttpStatusCode.NotFound); } - var dataset = new BasicTextDataset(textFilePath: ConfigurationManager.AppSettings["LocalDataDirectory"] + Path.DirectorySeparatorChar + "hnc1_tumor.txt"); + DatasetLoader datasetLoader = new DatasetLoader( + new DataRootConfig( + ConfigurationManager.AppSettings["LocalDataDirectory"], + ConfigurationManager.AppSettings["RemoteDataDirectory"])); + IDataset dataset = datasetLoader.GetFromName("hnc1_tumor.txt"); var mz = dataset.GetRawMzArray(); @@ -83,7 +90,11 @@ public Spectrum Get(int id, int x, int y) throw new HttpResponseException(HttpStatusCode.NotFound); } - var dataset = new BasicTextDataset(textFilePath: ConfigurationManager.AppSettings["LocalDataDirectory"] + Path.DirectorySeparatorChar + "hnc1_tumor.txt"); + DatasetLoader datasetLoader = new DatasetLoader( + new DataRootConfig( + ConfigurationManager.AppSettings["LocalDataDirectory"], + ConfigurationManager.AppSettings["RemoteDataDirectory"])); + IDataset dataset = datasetLoader.GetFromName("hnc1_tumor.txt"); var spectrumId = dataset.SpatialCoordinates.ToList() .FindIndex(sc => sc.X == x && sc.Y == y); From d9e49afa18eae5e79bcd34f204fb476855fafbe8 Mon Sep 17 00:00:00 2001 From: Sebaxp95 Date: Thu, 21 Sep 2017 19:54:23 +0200 Subject: [PATCH 08/97] preparation id in divik --- .../src/app/divik-results/divik/divik.component.html | 2 +- .../src/app/divik-results/divik/divik.component.ts | 10 +++++----- .../preparation/preparation.component.html | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html index 66cfcbf..a5d3087 100644 --- a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html +++ b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.html @@ -9,7 +9,7 @@ min="0" max={{divikConfig.Level}} (change)="changeLevel($event.target.value)"/> - Max value: divikConfig.Level + Max value: {{divikConfig.Level}} diff --git a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts index f155216..8a38379 100644 --- a/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts +++ b/src/Spectre.AngularClient/src/app/divik-results/divik/divik.component.ts @@ -17,7 +17,7 @@ limitations under the License. */ -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { ActivatedRoute} from '@angular/router'; import { DomSanitizer } from '@angular/platform-browser'; @@ -36,6 +36,7 @@ export class DivikComponent implements OnInit { public configDescription: string; public divikConfig: DivikConfig; public downloadJsonHref: any; + @Input() public preparationId; constructor( private route: ActivatedRoute, private divikService: DivikService, @@ -44,10 +45,10 @@ export class DivikComponent implements OnInit { ngOnInit() { this.divikService - .get(1, 1, 1) + .get(this.preparationId, 1, 1) .subscribe(heatmap => this.data = this.toHeatmapDataset(heatmap)); this.divikService - .getConfig(1, 1) + .getConfig(this.preparationId, 1) .subscribe(config => this.configDescription = this.buildConfigInfo(config)); } @@ -68,10 +69,9 @@ export class DivikComponent implements OnInit { } changeLevel(value) { - console.log('change ' + value); if (value > 0 && value <= this.divikConfig.Level) { this.divikService - .get(1, 1, value) + .get(this.preparationId, 1, value) .subscribe(heatmap => this.data = this.toHeatmapDataset(heatmap)); } } diff --git a/src/Spectre.AngularClient/src/app/preparations/preparation/preparation.component.html b/src/Spectre.AngularClient/src/app/preparations/preparation/preparation.component.html index 9aa047f..04722e1 100644 --- a/src/Spectre.AngularClient/src/app/preparations/preparation/preparation.component.html +++ b/src/Spectre.AngularClient/src/app/preparations/preparation/preparation.component.html @@ -18,6 +18,8 @@ - + + From fa09690a1fb19b6cc07d49c969ed7f6dd6e97eb3 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 21 Sep 2017 21:16:47 +0200 Subject: [PATCH 09/97] fixed pointed out issues --- .gitattributes | 77 ------------------- src/Spectre.Database.Tests/QueryTests.cs | 6 +- .../{Utils => Contexts}/Context.cs | 2 +- .../Migrations/Configuration.cs | 2 +- src/Spectre.Database/Spectre.Database.csproj | 3 +- src/Spectre.Database/Utils/IPathFinder.cs | 28 +++++++ src/Spectre.Database/Utils/PathFinder.cs | 67 ++++++++-------- 7 files changed, 69 insertions(+), 116 deletions(-) rename src/Spectre.Database/{Utils => Contexts}/Context.cs (96%) create mode 100644 src/Spectre.Database/Utils/IPathFinder.cs diff --git a/.gitattributes b/.gitattributes index 3d18c38..e69de29 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using NUnit.Framework; -using NUnit.Mocks; - -[TestFixture] -public class PersonServiceTest -{ -// The dynamic mock proxy that we will use to implement IPersonRepository -private DynamicMock personRepositoryMock; -// Set up some testing data -private Person onePerson = new Person("1", "Wendy", "Whiner"); -private Person secondPerson = new Person("2", "Aaron", "Adams"); -private List peopleList; -[SetUp] -public void TestInit() -{ -peopleList = new List(); -peopleList.Add(onePerson); -peopleList.Add(secondPerson); -// Construct a Mock Object of the IPersonRepository Interface -personRepositoryMock = new DynamicMock(typeof (IPersonRepository)); -} -[Test] -public void TestGetAllPeople() -{ -// Tell that mock object when the "GetPeople" method is -// called to return a predefined list of people -personRepositoryMock.ExpectAndReturn("GetPeople", peopleList); -// Construct a Person service with the Mock IPersonRepository -PersonService service = new PersonService( -(IPersonRepository) personRepositoryMock.MockInstance); -// Call methods and assert tests -Assert.AreEqual(2, service.GetAllPeople().Count); -} -[Test] -public void TestGetAllPeopleSorted() -{ -// Tell that mock object when the "GetPeople" method is called to -// return a predefined list of people -personRepositoryMock.ExpectAndReturn("GetPeople", peopleList); -PersonService service = new PersonService( -(IPersonRepository) personRepositoryMock.MockInstance); -// This method really has "business logic" in it - the sorting of people -List people = service.GetAllPeopleSorted(); -Assert.IsNotNull(people); -Assert.AreEqual(2, people.Count); -// Make sure the first person returned is the correct one -Person p = people[0]; -Assert.AreEqual("Adams", p.LastName); -} -[Test] -public void TestGetSinglePersonWithValidId() -{ -// Tell that mock object when the "GetPerson" method is called to -// return a predefined Person -personRepositoryMock.ExpectAndReturn("GetPersonById", onePerson, "1"); -PersonService service = new PersonService( -(IPersonRepository) personRepositoryMock.MockInstance); -Person p = service.GetPerson("1"); -Assert.IsNotNull(p); -Assert.AreEqual(p.Id, "1"); -} -[Test] -public void TestGetSinglePersonWithInalidId() -{ -// Tell that mock object when the "GetPersonById" is called with a null -// value to throw an ArgumentException -personRepositoryMock.ExpectAndThrow("GetPersonById", -new ArgumentException("Invalid person id."), null); -PersonService service = new PersonService( -(IPersonRepository) personRepositoryMock.MockInstance); -// The only way to get null is if the underlying IPersonRepository -// threw an ArgumentException -Assert.IsNull(service.GetPerson(null)); -} -} \ No newline at end of file diff --git a/src/Spectre.Database.Tests/QueryTests.cs b/src/Spectre.Database.Tests/QueryTests.cs index c13fd9a..059a0a9 100644 --- a/src/Spectre.Database.Tests/QueryTests.cs +++ b/src/Spectre.Database.Tests/QueryTests.cs @@ -23,19 +23,18 @@ limitations under the License. using System.Linq; using Spectre.Database.Entities; using Spectre.Database.Utils; +using Spectre.Database.Contexts; using System.Data.Entity; using Microsoft.VisualStudio.TestTools.UnitTesting; using NUnit.Framework; using NUnit.Mocks; using Moq; - namespace Spectre.Database.Tests { [TestFixture] public class QueryTests { - [Test] public void QueryTest() { @@ -55,13 +54,14 @@ public void QueryTest() var mockContext = new Mock(); mockContext.Setup(c => c.Datasets).Returns(mockSet.Object); - var service = new PathFinder(mockContext.Object); var dataset1 = service.ReturnForHash("1"); var dataset2 = service.ReturnForFriendlyName("Bajer2"); + var dataset3 = service.ReturnForHash("4"); NUnit.Framework.Assert.AreEqual("path1", dataset1); NUnit.Framework.Assert.AreEqual("path2", dataset2); + NUnit.Framework.Assert.AreEqual(null, dataset3); } } } diff --git a/src/Spectre.Database/Utils/Context.cs b/src/Spectre.Database/Contexts/Context.cs similarity index 96% rename from src/Spectre.Database/Utils/Context.cs rename to src/Spectre.Database/Contexts/Context.cs index fd32609..2478114 100644 --- a/src/Spectre.Database/Utils/Context.cs +++ b/src/Spectre.Database/Contexts/Context.cs @@ -20,7 +20,7 @@ limitations under the License. using System.Data.Entity; using Spectre.Database.Entities; -namespace Spectre.Database.Utils +namespace Spectre.Database.Contexts { /// /// Context for database access. diff --git a/src/Spectre.Database/Migrations/Configuration.cs b/src/Spectre.Database/Migrations/Configuration.cs index af5622d..e0733c4 100644 --- a/src/Spectre.Database/Migrations/Configuration.cs +++ b/src/Spectre.Database/Migrations/Configuration.cs @@ -25,7 +25,7 @@ namespace Spectre.Database.Migrations /// Configuration of dataset migrations. /// /// - internal sealed class Configuration : DbMigrationsConfiguration + internal sealed class Configuration : DbMigrationsConfiguration { /// /// Initializes a new instance of the class. diff --git a/src/Spectre.Database/Spectre.Database.csproj b/src/Spectre.Database/Spectre.Database.csproj index 49efd23..1063555 100644 --- a/src/Spectre.Database/Spectre.Database.csproj +++ b/src/Spectre.Database/Spectre.Database.csproj @@ -53,7 +53,8 @@ - + + diff --git a/src/Spectre.Database/Utils/IPathFinder.cs b/src/Spectre.Database/Utils/IPathFinder.cs new file mode 100644 index 0000000..2e08552 --- /dev/null +++ b/src/Spectre.Database/Utils/IPathFinder.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Spectre.Database.Utils +{ + /// + /// Interface for the PathFinder class + /// + public interface IPathFinder + { + /// + /// Returns for hash. + /// + /// The hash. + /// Hash + string ReturnForHash(string hash); + + /// + /// Returns the name of for friendly. + /// + /// The friendlyname. + /// Friendly Name + string ReturnForFriendlyName(string friendlyname); + } +} diff --git a/src/Spectre.Database/Utils/PathFinder.cs b/src/Spectre.Database/Utils/PathFinder.cs index 06a27da..706f0a2 100644 --- a/src/Spectre.Database/Utils/PathFinder.cs +++ b/src/Spectre.Database/Utils/PathFinder.cs @@ -17,40 +17,31 @@ You may obtain a copy of the License at limitations under the License. */ -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Spectre.Database.Entities; - namespace Spectre.Database.Utils { + using System; + using System.Collections.Generic; + using System.Data.Entity; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + using Spectre.Database.Contexts; + using Spectre.Database.Entities; + /// /// Class for finding the path of chosen property. /// - public class PathFinder + public class PathFinder : IPathFinder { /// - /// Variable for returning location from hash - /// - private static string _locationfromhash; - - /// - /// Variable for returning location from friendly name - /// - private static string _locationfromfriendlyname; - - /// - /// The location + /// The context description /// - private Dataset _path = new Dataset(); + private Context _context; /// - /// The context description + /// The dataset /// - private Context _context; + private Dataset _dataset = new Dataset(); /// /// Initializes a new instance of the class. @@ -68,15 +59,20 @@ public PathFinder(Context context) /// /// Returns location having hash. /// - public string ReturnForHash(string hash) + public virtual string ReturnForHash(string hash) { - _path = _context.Datasets + if (_context.Datasets.Any(o => o.Hash == hash)) + { + _dataset = _context.Datasets .Where(b => b.Hash == hash) .FirstOrDefault(); - PathFinder._locationfromhash = _path.Location.ToString(); - - return PathFinder._locationfromhash; + return _dataset.Location.ToString(); + } + else + { + return null; + } } /// @@ -86,15 +82,20 @@ public string ReturnForHash(string hash) /// /// Returns location having friendly name. /// - public string ReturnForFriendlyName(string friendlyname) + public virtual string ReturnForFriendlyName(string friendlyname) { - _path = _context.Datasets + if (_context.Datasets.Any(o => o.FriendlyName == friendlyname)) + { + _dataset = _context.Datasets .Where(b => b.FriendlyName == friendlyname) .FirstOrDefault(); - PathFinder._locationfromfriendlyname = _path.Location.ToString(); - - return PathFinder._locationfromfriendlyname; + return _dataset.Location.ToString(); + } + else + { + return null; + } } } } From adb844b0edb286cd90eff126ba472e37713e4475 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 21 Sep 2017 21:22:26 +0200 Subject: [PATCH 10/97] fixed pointed out issues --- src/Spectre.Database.Tests/QueryTests.cs | 4 +--- src/Spectre.Database/Migrations/Configuration.cs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Spectre.Database.Tests/QueryTests.cs b/src/Spectre.Database.Tests/QueryTests.cs index 059a0a9..8b18b5a 100644 --- a/src/Spectre.Database.Tests/QueryTests.cs +++ b/src/Spectre.Database.Tests/QueryTests.cs @@ -64,6 +64,4 @@ public void QueryTest() NUnit.Framework.Assert.AreEqual(null, dataset3); } } -} - - +} \ No newline at end of file diff --git a/src/Spectre.Database/Migrations/Configuration.cs b/src/Spectre.Database/Migrations/Configuration.cs index e0733c4..1472446 100644 --- a/src/Spectre.Database/Migrations/Configuration.cs +++ b/src/Spectre.Database/Migrations/Configuration.cs @@ -24,7 +24,7 @@ namespace Spectre.Database.Migrations /// /// Configuration of dataset migrations. /// - /// + /// internal sealed class Configuration : DbMigrationsConfiguration { /// From d9fc0ae97db40dd88dd63f48af64c9905bf27389 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 22 Sep 2017 19:56:34 +0200 Subject: [PATCH 11/97] added pathfinder service --- src/Spectre.Database.Tests/QueryTests.cs | 2 +- .../Abstract/IPathFinderService.cs | 53 ++++++++++++++++ .../Abstract/IServiceFactory.cs | 6 ++ src/Spectre.Service/PathFinderService.cs | 60 +++++++++++++++++++ src/Spectre.Service/ServiceFactory.cs | 11 ++++ src/Spectre.Service/Spectre.Service.csproj | 6 ++ 6 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/Spectre.Service/Abstract/IPathFinderService.cs create mode 100644 src/Spectre.Service/PathFinderService.cs diff --git a/src/Spectre.Database.Tests/QueryTests.cs b/src/Spectre.Database.Tests/QueryTests.cs index 8b18b5a..2ce4a92 100644 --- a/src/Spectre.Database.Tests/QueryTests.cs +++ b/src/Spectre.Database.Tests/QueryTests.cs @@ -53,7 +53,7 @@ public void QueryTest() var mockContext = new Mock(); mockContext.Setup(c => c.Datasets).Returns(mockSet.Object); - + var service = new PathFinder(mockContext.Object); var dataset1 = service.ReturnForHash("1"); var dataset2 = service.ReturnForFriendlyName("Bajer2"); diff --git a/src/Spectre.Service/Abstract/IPathFinderService.cs b/src/Spectre.Service/Abstract/IPathFinderService.cs new file mode 100644 index 0000000..fdbd3a8 --- /dev/null +++ b/src/Spectre.Service/Abstract/IPathFinderService.cs @@ -0,0 +1,53 @@ +/* + * IPathFinderService.cs + * Class providing interface for PathFinderService + * + Copyright 2017 Roman Lisak + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +namespace Spectre.Service.Abstract +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + using Spectre.Database.Contexts; + using Spectre.Database.Utils; + + /// + /// Interface for PathFinderService + /// + public interface IPathFinderService + { + /// + /// Finds the hash using friendly name. + /// + /// The hash. + /// + /// Friendly name basing on hash + /// + string FindHash(string hash); + + /// + /// Finds the friendky name using hash. + /// + /// The friendlyname. + /// + /// Hash basing on riendly name + /// + string FindFriendlyName(string friendlyname); + } +} diff --git a/src/Spectre.Service/Abstract/IServiceFactory.cs b/src/Spectre.Service/Abstract/IServiceFactory.cs index e1428b9..db4a551 100644 --- a/src/Spectre.Service/Abstract/IServiceFactory.cs +++ b/src/Spectre.Service/Abstract/IServiceFactory.cs @@ -36,5 +36,11 @@ public interface IServiceFactory /// The update interval. /// IConsoleCaptureService instance IConsoleCaptureService GetConsoleCaptureService(double updateInterval = 1000.0); + + /// + /// Gets the path finder service. + /// + /// IPathFinderInstance + IPathFinderService GetPathFinderService(); } } diff --git a/src/Spectre.Service/PathFinderService.cs b/src/Spectre.Service/PathFinderService.cs new file mode 100644 index 0000000..cc9cd75 --- /dev/null +++ b/src/Spectre.Service/PathFinderService.cs @@ -0,0 +1,60 @@ +namespace Spectre.Service +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + using Spectre.Database.Contexts; + using Spectre.Database.Utils; + using Spectre.Service.Abstract; + + /// + /// PathFinder service. + /// + /// + internal class PathFinderService : IPathFinderService + { + /// + /// The context + /// + private static Context _context; + + /// + /// The service + /// + private readonly PathFinder _service = new PathFinder(PathFinderService._context); + + /// + /// Initializes a new instance of the class. + /// + public PathFinderService() + { + PathFinderService._context = new Context(); + } + + /// + /// Finds the hash. + /// + /// The hash. + /// + /// Friendly name basing on hash + /// + public string FindHash(string hash) + { + return _service.ReturnForHash(hash); + } + + /// + /// Finds the friendly name. + /// + /// The friendlyname. + /// + /// Hash basing on riendly name + /// + public string FindFriendlyName(string friendlyname) + { + return _service.ReturnForFriendlyName(friendlyname); + } + } +} diff --git a/src/Spectre.Service/ServiceFactory.cs b/src/Spectre.Service/ServiceFactory.cs index 70dd369..d1ab512 100644 --- a/src/Spectre.Service/ServiceFactory.cs +++ b/src/Spectre.Service/ServiceFactory.cs @@ -44,5 +44,16 @@ public IConsoleCaptureService GetConsoleCaptureService(double updateInterval = 1 { return new ConsoleCaptureService(updateInterval); } + + /// + /// Gets the path finder service. + /// + /// + /// IPathFinderInstance + /// + public IPathFinderService GetPathFinderService() + { + return new PathFinderService(); + } } } diff --git a/src/Spectre.Service/Spectre.Service.csproj b/src/Spectre.Service/Spectre.Service.csproj index c9b0a5b..ecf3a7d 100644 --- a/src/Spectre.Service/Spectre.Service.csproj +++ b/src/Spectre.Service/Spectre.Service.csproj @@ -47,9 +47,11 @@ + + @@ -63,6 +65,10 @@ {9a886aec-58db-410d-91b9-c62e157501fa} Spectre.Algorithms + + {b5b60f79-653c-4e41-9721-06c478ce9e7c} + Spectre.Database + {70C87AF7-3189-4F6C-AC85-93309CF7CFDC} Spectre.Data From f1ea70d23238edd5bcc154ccafc12fa445f8b0d3 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 22 Sep 2017 20:34:09 +0200 Subject: [PATCH 12/97] added pathfinder service --- src/Spectre.Service/Abstract/IServiceFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spectre.Service/Abstract/IServiceFactory.cs b/src/Spectre.Service/Abstract/IServiceFactory.cs index db4a551..094a548 100644 --- a/src/Spectre.Service/Abstract/IServiceFactory.cs +++ b/src/Spectre.Service/Abstract/IServiceFactory.cs @@ -2,7 +2,7 @@ * IServiceFactory.cs * Contains definition of interface for Factory for creating services. * - Copyright 2017 Michał Wolny, Grzegorz Mrukwa + Copyright 2017 Michał Wolny, Grzegorz Mrukwa, Roman Lisak Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 2b2b97c24a5d770892907dcfd53ff08f9d5bd707 Mon Sep 17 00:00:00 2001 From: Sebaxp95 Date: Sat, 14 Oct 2017 12:17:54 +0200 Subject: [PATCH 13/97] click on heatmap and chnange material md to mat --- src/Spectre.AngularClient/package.json | 25 ++++---- .../src/app/app.component.html | 20 +++---- .../src/app/app.component.spec.ts | 4 +- .../src/app/app.module.ts | 6 +- .../divik-results/divik/divik.component.html | 28 ++++----- .../divik/divik.component.spec.ts | 4 +- .../heatmaps/heatmap/heatmap.component.html | 3 +- .../heatmap/heatmap.component.spec.ts | 2 +- .../app/heatmaps/heatmap/heatmap.component.ts | 2 +- .../src/app/plotly/PlotHTMLElement.ts | 3 + .../src/app/plotly/plotly.component.ts | 3 + .../preparation/preparation.component.html | 58 ++++++++++--------- .../preparation/preparation.component.spec.ts | 8 +-- .../preparation/preparation.component.ts | 9 +++ .../app/preparations/preparations.module.ts | 16 ++--- .../spectrum/spectrum.component.spec.ts | 2 +- 16 files changed, 106 insertions(+), 87 deletions(-) create mode 100644 src/Spectre.AngularClient/src/app/plotly/PlotHTMLElement.ts diff --git a/src/Spectre.AngularClient/package.json b/src/Spectre.AngularClient/package.json index 86df5dd..026d3e5 100644 --- a/src/Spectre.AngularClient/package.json +++ b/src/Spectre.AngularClient/package.json @@ -52,18 +52,19 @@ }, "private": true, "dependencies": { - "@angular/animations": "^5.0.0-beta.0", - "@angular/cdk": "^2.0.0-beta.8", - "@angular/common": "^5.0.0-beta.0", - "@angular/compiler": "^5.0.0-beta.0", - "@angular/core": "^5.0.0-beta.0", - "@angular/forms": "^5.0.0-beta.0", - "@angular/http": "^5.0.0-beta.0", - "@angular/material": "^2.0.0-beta.10", - "@angular/platform-browser": "^5.0.0-beta.0", - "@angular/platform-browser-dynamic": "^5.0.0-beta.0", - "@angular/platform-server": "^5.0.0-beta.0", - "@angular/router": "^5.0.0-beta.0", + "@angular/animations": "^5.0.0-rc.1", + "@angular/cdk": "^2.0.0-beta.12", + "@angular/common": "^5.0.0-rc.1", + "@angular/compiler": "^5.0.0-rc.1", + "@angular/compiler-cli": "^5.0.0-rc.1", + "@angular/core": "^5.0.0-rc.1", + "@angular/forms": "^5.0.0-rc.1", + "@angular/http": "^5.0.0-rc.1", + "@angular/material": "^2.0.0-beta.12", + "@angular/platform-browser": "^5.0.0-rc.1", + "@angular/platform-browser-dynamic": "^5.0.0-rc.1", + "@angular/platform-server": "^5.0.0-rc.1", + "@angular/router": "^5.0.0-rc.1", "bootstrap": "^3.3.7", "core-js": "^2.4.1", "font-awesome": "^4.7.0", diff --git a/src/Spectre.AngularClient/src/app/app.component.html b/src/Spectre.AngularClient/src/app/app.component.html index 23cb9f4..2254822 100644 --- a/src/Spectre.AngularClient/src/app/app.component.html +++ b/src/Spectre.AngularClient/src/app/app.component.html @@ -1,5 +1,5 @@ - - + - +