Skip to content

Commit

Permalink
fix: update broken tests to work on .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
natemcmaster committed Dec 26, 2024
1 parent e81e4ea commit ccd68aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
25 changes: 8 additions & 17 deletions test/Plugins.Tests/BasicAssemblyLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
using McMaster.Extensions.Xunit;
using Test.Referenced.Library;
using Xunit;
using Xunit.Abstractions;

namespace McMaster.NETCore.Plugins.Tests
{
public class BasicAssemblyLoaderTests
{
private readonly ITestOutputHelper output;

public BasicAssemblyLoaderTests(ITestOutputHelper output)
{
this.output = output;
}

[Fact]
public void PluginLoaderCanUnload()
{
Expand Down Expand Up @@ -108,23 +116,6 @@ public void LoadsNetStandard20Project()
Assert.Equal("Red", method!.Invoke(Activator.CreateInstance(type), Array.Empty<object>()));
}

[Fact]
public void ItPrefersRuntimeSpecificManagedAssetsOverRidlessOnes()
{
// System.Drawing.Common is an example of a package which has both rid-specific and ridless versions
// The package has lib/netstandard2.0/System.Drawing.Common.dll, but also has runtimes/{win,unix}/lib/netcoreapp2.0/System.Drawing.Common.dll
// In this case, the host will pick the rid-specific version

var path = TestResources.GetTestProjectAssembly("DrawingApp");
var loader = PluginLoader.CreateFromAssemblyFile(path);
var assembly = loader.LoadDefaultAssembly();

var type = assembly.GetType("Finder", throwOnError: true)!;
var method = type.GetMethod("FindDrawingAssembly", BindingFlags.Static | BindingFlags.Public);
Assert.NotNull(method);
Assert.Contains("runtimes", (string?)method!.Invoke(null, Array.Empty<object>()));
}

[Fact]
[UseCulture("es")]
public void ItLoadsSatelliteAssemblies()
Expand Down
4 changes: 2 additions & 2 deletions test/TestProjects/DrawingApp/DrawingApp.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion test/TestProjects/NativeDependency/NativeDependency.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.11" />
</ItemGroup>

</Project>
5 changes: 3 additions & 2 deletions test/TestProjects/NativeDependency/NativeDependencyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.SQLite;
using System.IO;

using Microsoft.Data.Sqlite;

namespace NativeDependency
{
public static class NativeDependencyLoader
{
public static void Load()
{
using var tempFile = new TempFile("db.sqlite");
using var dbConnection = new SQLiteConnection($"Data Source={tempFile.FilePath}");
using var dbConnection = new SqliteConnection($"Data Source={tempFile.FilePath}");

dbConnection.Open();
}
Expand Down

0 comments on commit ccd68aa

Please sign in to comment.