From 301d21a56fa5e3dbb1140d5e095ae8a49aed27eb Mon Sep 17 00:00:00 2001 From: hlotyaks Date: Thu, 2 Jan 2020 20:25:19 -0500 Subject: [PATCH 1/3] package hasher - renamed tests --- GraphBuilder/tests/Graph.Tests.cs | 10 ++++---- GraphBuilder/tests/GraphBuilder.Tests.cs | 8 +++--- PackageHasher/tests/PackageHaser.Tests.cs | 31 ++++++++++++++++++++--- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/GraphBuilder/tests/Graph.Tests.cs b/GraphBuilder/tests/Graph.Tests.cs index 6bdbbb7..cbe80a1 100644 --- a/GraphBuilder/tests/Graph.Tests.cs +++ b/GraphBuilder/tests/Graph.Tests.cs @@ -6,7 +6,7 @@ namespace PackageAnalyzer.Tests public class GraphTests { [TestMethod] - public void SimpleCycleTest1() + public void SimpleGraphCycleTest1() { GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle1"); @@ -14,7 +14,7 @@ public void SimpleCycleTest1() } [TestMethod] - public void SimpleCycleTest2() + public void SimpleGraphCycleTest2() { GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle2"); @@ -23,7 +23,7 @@ public void SimpleCycleTest2() [TestMethod] - public void SimpleCycleTest3() + public void SimplGraphCycleTest3() { GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle3"); @@ -31,7 +31,7 @@ public void SimpleCycleTest3() } [TestMethod] - public void SimpleCycleTest4() + public void SimpleGraphCycleTest4() { GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle4"); @@ -39,7 +39,7 @@ public void SimpleCycleTest4() } [TestMethod] - public void IntermediateCycleTest1() + public void IntermediateGraphCycleTest1() { GraphBuilder gb = GraphTestUtilities.PopulateGB("intermediatecycle1"); diff --git a/GraphBuilder/tests/GraphBuilder.Tests.cs b/GraphBuilder/tests/GraphBuilder.Tests.cs index a7209fb..1de6abf 100644 --- a/GraphBuilder/tests/GraphBuilder.Tests.cs +++ b/GraphBuilder/tests/GraphBuilder.Tests.cs @@ -10,7 +10,7 @@ public class GraphBuilderTests [TestMethod] - public void SimpleTest1() + public void SimpleGraphBuilderTest1() { GraphBuilder gb = new GraphBuilder(); @@ -29,7 +29,7 @@ public void SimpleTest1() } [TestMethod] - public void SimpleTest2() + public void SimpleGraphBuilderTest2() { GraphBuilder gb = GraphTestUtilities.PopulateGB("simple2"); @@ -42,7 +42,7 @@ public void SimpleTest2() } [TestMethod] - public void SimpleTest3() + public void SimpleGraphBuilderTest3() { GraphBuilder gb = GraphTestUtilities.PopulateGB("simple3"); @@ -58,7 +58,7 @@ public void SimpleTest3() [TestMethod] [ExpectedException(typeof(GraphBuilderException))] - public void FailTest1() + public void FailGraphBuilderTest1() { // tests the top level package field is malformed GraphBuilder gb = GraphTestUtilities.PopulateGB("failure1"); diff --git a/PackageHasher/tests/PackageHaser.Tests.cs b/PackageHasher/tests/PackageHaser.Tests.cs index ce3356a..f602ee9 100644 --- a/PackageHasher/tests/PackageHaser.Tests.cs +++ b/PackageHasher/tests/PackageHaser.Tests.cs @@ -11,12 +11,12 @@ namespace PackageAnalyzer.Tests public class PackageHasherTests { [TestMethod] - public void SimpleTest1() + public void SimpleHashTest1() { PackageHasher ph = new PackageHasher(); string cwd = Directory.GetCurrentDirectory(); - string root = $"{cwd}\\testcases\\simple2"; + string root = $"{cwd}\\testcases\\simple1"; List paths = new List(); paths.Add($"{root}\\package1"); @@ -30,7 +30,7 @@ public void SimpleTest1() } [TestMethod] - public void SimpleTest2() + public void SimpleHashTest2() { PackageHasher ph = new PackageHasher(); @@ -49,6 +49,31 @@ public void SimpleTest2() Assert.IsTrue(result.ContainsKey("package1")); Assert.IsTrue(result.ContainsKey("package2")); } + + [TestMethod] + public void CompareHashTest1() + { + // compare hash of same folder and contents from 2 different roots. Should have the smae hash value. + PackageHasher ph = new PackageHasher(); + + string cwd = Directory.GetCurrentDirectory(); + string root1 = $"{cwd}\\testcases\\simple1"; + string root2 = $"{cwd}\\testcases\\simple2"; + + List paths1 = new List(); + paths1.Add($"{root1}\\package1"); + + List paths2 = new List(); + paths2.Add($"{root2}\\package1"); + + var task1 = Task.Run(async () => await ph.HashFoldersAsync(paths1, root1)); + var result1 = task1.Result; + + var task2 = Task.Run(async () => await ph.HashFoldersAsync(paths2, root2)); + var result2 = task2.Result; + + Assert.AreEqual(result1["package1"], result2["package1"]); + } } } \ No newline at end of file From 02993771996b7723fe209c0a2335b16a229ea4bf Mon Sep 17 00:00:00 2001 From: hlotyaks Date: Fri, 3 Jan 2020 08:43:07 -0500 Subject: [PATCH 2/3] add package builder --- PackageBuilder/PackageBuilder.sln | 48 ++++++++++++++++++++ PackageBuilder/src/PackageBuilder.cs | 23 ++++++++++ PackageBuilder/src/PackageBuilder.csproj | 7 +++ PackageBuilder/tests/PackageBuilder.Tests.cs | 24 ++++++++++ PackageBuilder/tests/tests.csproj | 24 ++++++++++ 5 files changed, 126 insertions(+) create mode 100644 PackageBuilder/PackageBuilder.sln create mode 100644 PackageBuilder/src/PackageBuilder.cs create mode 100644 PackageBuilder/src/PackageBuilder.csproj create mode 100644 PackageBuilder/tests/PackageBuilder.Tests.cs create mode 100644 PackageBuilder/tests/tests.csproj diff --git a/PackageBuilder/PackageBuilder.sln b/PackageBuilder/PackageBuilder.sln new file mode 100644 index 0000000..4cb979b --- /dev/null +++ b/PackageBuilder/PackageBuilder.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageBuilder", "src\PackageBuilder.csproj", "{90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tests", "tests\tests.csproj", "{662F222A-57E6-47F8-B7D1-F425DC50254F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Debug|x64.ActiveCfg = Debug|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Debug|x64.Build.0 = Debug|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Debug|x86.ActiveCfg = Debug|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Debug|x86.Build.0 = Debug|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Release|Any CPU.Build.0 = Release|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Release|x64.ActiveCfg = Release|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Release|x64.Build.0 = Release|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Release|x86.ActiveCfg = Release|Any CPU + {90D2F559-6EEA-4FE6-8CB3-79A3090CCC61}.Release|x86.Build.0 = Release|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Debug|x64.ActiveCfg = Debug|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Debug|x64.Build.0 = Debug|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Debug|x86.ActiveCfg = Debug|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Debug|x86.Build.0 = Debug|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Release|Any CPU.Build.0 = Release|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Release|x64.ActiveCfg = Release|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Release|x64.Build.0 = Release|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Release|x86.ActiveCfg = Release|Any CPU + {662F222A-57E6-47F8-B7D1-F425DC50254F}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/PackageBuilder/src/PackageBuilder.cs b/PackageBuilder/src/PackageBuilder.cs new file mode 100644 index 0000000..deeebee --- /dev/null +++ b/PackageBuilder/src/PackageBuilder.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace PackageAnalyzer +{ + public class PackageBuilder + { + // location relative to specified rootFolder. + const string PACKAGE_DESCRIPTIONS = "packages//descriptions"; + const string PACKAGE_CACHE = "packages//cache"; + const string PACKAGE_SOURCE = "src"; + const string PACKAGE_OUTPUT = "output"; + + + + public List Build(string start, string rootFolder) + { + List builtPackages = new List(); + + return builtPackages; + } + } +} diff --git a/PackageBuilder/src/PackageBuilder.csproj b/PackageBuilder/src/PackageBuilder.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/PackageBuilder/src/PackageBuilder.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/PackageBuilder/tests/PackageBuilder.Tests.cs b/PackageBuilder/tests/PackageBuilder.Tests.cs new file mode 100644 index 0000000..f392852 --- /dev/null +++ b/PackageBuilder/tests/PackageBuilder.Tests.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.IO; +using System.Collections.Generic; + +namespace PackageAnalyzer.Tests +{ + [TestClass] + public class PackageBuilderTests + { + [TestMethod] + public void SimpleBuilderTest1() + { + PackageBuilder pb = new PackageBuilder(); + + string cwd = Directory.GetCurrentDirectory(); + + DirectoryInfo di = new DirectoryInfo($"{cwd}\\testcases\\simple1"); + + List buildResults = pb.Build("A", di.FullName); + + Assert.AreEqual(0, buildResults.Count); + } + } +} diff --git a/PackageBuilder/tests/tests.csproj b/PackageBuilder/tests/tests.csproj new file mode 100644 index 0000000..0efa5da --- /dev/null +++ b/PackageBuilder/tests/tests.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp3.0 + + false + + + + + + + + + + + + + + + + + + From ac610b17df23355d452b48126c07cc5348620581 Mon Sep 17 00:00:00 2001 From: hlotyaks Date: Fri, 3 Jan 2020 08:44:17 -0500 Subject: [PATCH 3/3] add package builder to ci script --- .github/workflows/dotnetcore.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 39b0713..6f830b3 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -15,9 +15,15 @@ jobs: dotnet-version: 2.2.108 - name: Build - GraphBuilder run: dotnet build GraphBuilder/GraphBuilder.sln -c Release - - name: Build - PackageHasher - run: dotnet build PackageHasher/PackageHasher.sln -c Release - name: Test - GraphBuilder run: dotnet test GraphBuilder/tests/tests.csproj -c Release -v m + + - name: Build - PackageHasher + run: dotnet build PackageHasher/PackageHasher.sln -c Release - name: Test - PackageHasher run: dotnet test PackageHasher/tests/tests.csproj -c Release -v m + + - name: Build - PackageBuilder + run: dotnet build PackageBuilder/PackageBuilder.sln -c Release + - name: Test - PackageBuilder + run: dotnet test PackageBuilder/tests/tests.csproj -c Release -v m