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

update nuget packages and tests #129

Merged
merged 1 commit into from
Dec 27, 2024
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
Update packages and improve tests
  • Loading branch information
sensslen committed Dec 27, 2024
commit bb521ad4531e7738403c81e758ba409a53cd702c
2 changes: 1 addition & 1 deletion .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
- name: build
run: msbuild -t:rebuild -property:Configuration=TestWindows

- name: test
- name: test (${{ matrix.framework }})
uses: josepho0918/vstest-action@main
with:
testAssembly: "NuGetUtility.Test.dll"
Expand Down
4 changes: 2 additions & 2 deletions src/NuGetUtility/NuGetUtility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" Version="17.12.*" />
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" Version="17.11.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
Expand All @@ -48,7 +48,7 @@
<PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="9.0.0" />
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" Version="17.12.*" />
<PackageReference Include="PolySharp" Version="1.14.*">
<PackageReference Include="PolySharp" Version="1.15.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion tests/NuGetUtility.Test/NuGetUtility.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="PolySharp" Version="1.14.*">
<PackageReference Include="PolySharp" Version="1.15.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{SolutionDirectory}tests\targets\PackageReferenceProject\PackageReferenceProject.csproj,{SolutionDirectory}tests\targets\PackagesConfigProject\PackagesConfigProject.csproj,{SolutionDirectory}tests\targets\ProjectWithoutNugetReferences\ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveNuget\ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveReferences\ProjectWithTransitiveReferences.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{SolutionDirectory}tests\targets\PackageReferenceProject\PackageReferenceProject.csproj,{SolutionDirectory}tests\targets\PackagesConfigProject\PackagesConfigProject.csproj,{SolutionDirectory}tests\targets\ProjectWithoutNugetReferences\ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveNuget\ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveReferences\ProjectWithTransitiveReferences.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace NuGetUtility.Test.ReferencedPackagesReader
[TestFixture]
public class ProjectsCollectorTest
{
public ProjectsCollectorTest()
{
_osPlatformSpecificVerifySettings = new();
_osPlatformSpecificVerifySettings.UniqueForOSPlatform();
}

[SetUp]
public void SetUp()
Expand All @@ -23,6 +28,7 @@ public void SetUp()
private IMsBuildAbstraction _msBuild = null!;
private ProjectsCollector _uut = null!;
private Fixture _fixture = null!;
private readonly VerifySettings _osPlatformSpecificVerifySettings;

[TestCase("A.csproj")]
[TestCase("B.fsproj")]
Expand Down Expand Up @@ -107,22 +113,22 @@ public void GetProjects_Should_ReturnOnlyExistingProjectsInSolutionFile(string s
}

[Test]
public void GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath()
public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath()
{
var msbuild = new MsBuildAbstraction();
IEnumerable<string> result = msbuild.GetProjectsFromSolution("../../../../targets/Projects.sln");
Assert.That(result.Count(), Is.EqualTo(5));
await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings);
}

[Test]
public void GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath()
public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath()
{
var msbuild = new MsBuildAbstraction();
IEnumerable<string> result = msbuild.GetProjectsFromSolution(Path.GetFullPath("../../../../targets/Projects.sln"));
Assert.That(result.Count(), Is.EqualTo(5));
await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings);
}

private void CreateFiles(IEnumerable<string> files)
private static void CreateFiles(IEnumerable<string> files)
{
foreach (string file in files)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void GetInstalledPackagesShould_ReturnResolvedDependency_For_ProjectWithR

IEnumerable<PackageIdentity> result = _uut!.GetInstalledPackages(path, includeTransitive);

Assert.That(result.Count, Is.EqualTo(includeTransitive ? 2 : 1));
Assert.That(result.Count, Is.EqualTo(includeTransitive ? 3 : 1));
}

[Test]
Expand Down Expand Up @@ -155,15 +155,15 @@ public void GetInstalledPackagesShould_ThrowError_For_PackagesForNativeCppProjec
[TestCase("net8.0", false, "Microsoft.Extensions.Logging.Abstractions")]
[TestCase("net8.0-browser", false, "Microsoft.Extensions.Logging.Abstractions")]
[TestCase("net6.0", true, "TinyCsvParser")]
[TestCase("net8.0", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions")]
[TestCase("net8.0-browser", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions")]
[TestCase("net8.0", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions", "System.Diagnostics.DiagnosticSource")]
[TestCase("net8.0-browser", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions", "System.Diagnostics.DiagnosticSource")]
public void GetInstalledPackagesShould_OnlyReturn_PackagesPackagesReferencedByRequestedFramework(string framework, bool includeTransitive, params string[] packages)
{
string path = Path.GetFullPath("../../../../targets/MultiTargetProjectWithDifferentDependencies/MultiTargetProjectWithDifferentDependencies.csproj");

IEnumerable<PackageIdentity> result = _uut!.GetInstalledPackages(path, includeTransitive, framework);

Assert.That(packages, Is.EquivalentTo(result.Select(p => p.Id)));
Assert.That(result.Select(p => p.Id), Is.EquivalentTo(packages));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<PackageReference Include="TinyCsvParser" Version="2.7.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-browser'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TinyCsvParser, Version=2.7.0.0, Culture=neutral, PublicKeyToken=d7df35b038077099, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\TinyCsvParser.2.7.0\lib\netstandard2.0\TinyCsvParser.dll</HintPath>
<Reference Include="TinyCsvParser, Version=2.7.1.0, Culture=neutral, PublicKeyToken=d7df35b038077099, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\TinyCsvParser.2.7.1\lib\netstandard2.0\TinyCsvParser.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/targets/PackagesConfigProject/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="TinyCsvParser" version="2.7.0" targetFramework="net472" />
<package id="TinyCsvParser" version="2.7.1" targetFramework="net472" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="[8.0.2]" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="[9.0.0]" />
</ItemGroup>

</Project>
Loading