Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/add package hasher #6

Merged
merged 3 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions GraphBuilder/tests/Graph.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace PackageAnalyzer.Tests
public class GraphTests
{
[TestMethod]
public void SimpleCycleTest1()
public void SimpleGraphCycleTest1()
{
GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle1");

Assert.IsTrue(gb.Graph.IsCyclic);
}

[TestMethod]
public void SimpleCycleTest2()
public void SimpleGraphCycleTest2()
{
GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle2");

Expand All @@ -23,23 +23,23 @@ public void SimpleCycleTest2()


[TestMethod]
public void SimpleCycleTest3()
public void SimplGraphCycleTest3()
{
GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle3");

Assert.IsTrue(gb.Graph.IsCyclic);
}

[TestMethod]
public void SimpleCycleTest4()
public void SimpleGraphCycleTest4()
{
GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle4");

Assert.IsTrue(gb.Graph.IsCyclic);
}

[TestMethod]
public void IntermediateCycleTest1()
public void IntermediateGraphCycleTest1()
{
GraphBuilder gb = GraphTestUtilities.PopulateGB("intermediatecycle1");

Expand Down
8 changes: 4 additions & 4 deletions GraphBuilder/tests/GraphBuilder.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class GraphBuilderTests


[TestMethod]
public void SimpleTest1()
public void SimpleGraphBuilderTest1()
{
GraphBuilder gb = new GraphBuilder();

Expand All @@ -29,7 +29,7 @@ public void SimpleTest1()
}

[TestMethod]
public void SimpleTest2()
public void SimpleGraphBuilderTest2()
{
GraphBuilder gb = GraphTestUtilities.PopulateGB("simple2");

Expand All @@ -42,7 +42,7 @@ public void SimpleTest2()
}

[TestMethod]
public void SimpleTest3()
public void SimpleGraphBuilderTest3()
{
GraphBuilder gb = GraphTestUtilities.PopulateGB("simple3");

Expand All @@ -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");
Expand Down
48 changes: 48 additions & 0 deletions PackageBuilder/PackageBuilder.sln
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions PackageBuilder/src/PackageBuilder.cs
Original file line number Diff line number Diff line change
@@ -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<string> Build(string start, string rootFolder)
{
List<string> builtPackages = new List<string>();

return builtPackages;
}
}
}
7 changes: 7 additions & 0 deletions PackageBuilder/src/PackageBuilder.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
24 changes: 24 additions & 0 deletions PackageBuilder/tests/PackageBuilder.Tests.cs
Original file line number Diff line number Diff line change
@@ -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<string> buildResults = pb.Build("A", di.FullName);

Assert.AreEqual(0, buildResults.Count);
}
}
}
24 changes: 24 additions & 0 deletions PackageBuilder/tests/tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\PackageBuilder.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="testcases\**\*.*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
31 changes: 28 additions & 3 deletions PackageHasher/tests/PackageHaser.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> paths = new List<string>();
paths.Add($"{root}\\package1");
Expand All @@ -30,7 +30,7 @@ public void SimpleTest1()
}

[TestMethod]
public void SimpleTest2()
public void SimpleHashTest2()
{
PackageHasher ph = new PackageHasher();

Expand All @@ -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<string> paths1 = new List<string>();
paths1.Add($"{root1}\\package1");

List<string> paths2 = new List<string>();
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"]);
}
}

}