- Create MigrationTool console app for exporting DB config to K8s YAML - Support dry-run mode and validation - Add Npgsql and YamlDotNet dependencies
65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using System.Reflection;
|
|
using Xunit;
|
|
using YarpGateway.Plugins;
|
|
|
|
namespace YarpGateway.Tests.Unit.Plugins;
|
|
|
|
public class PluginLoadContextTests
|
|
{
|
|
private const string SharedAssemblyName = "Fengling.Gateway.Plugin.Abstractions";
|
|
|
|
[Fact]
|
|
public void Constructor_ShouldInitializeWithPluginPath()
|
|
{
|
|
// Arrange
|
|
var pluginPath = Path.Combine(Path.GetTempPath(), "test-plugin");
|
|
|
|
// Act
|
|
var context = new PluginLoadContext(pluginPath);
|
|
|
|
// Assert
|
|
Assert.NotNull(context);
|
|
}
|
|
|
|
[Fact]
|
|
public void LoadAssembly_SharedAssembly_ShouldReturnNull_UseDefaultALC()
|
|
{
|
|
// Arrange
|
|
var pluginPath = Path.Combine(Path.GetTempPath(), "test-plugin");
|
|
var context = new PluginLoadContext(pluginPath);
|
|
var assemblyName = new AssemblyName(SharedAssemblyName);
|
|
|
|
// Act
|
|
var assembly = context.LoadAssembly(assemblyName);
|
|
|
|
// Assert - null means use default ALC
|
|
Assert.Null(assembly);
|
|
}
|
|
|
|
[Fact]
|
|
public void LoadAssembly_UnknownAssembly_ShouldReturnNull()
|
|
{
|
|
// Arrange
|
|
var pluginPath = Path.Combine(Path.GetTempPath(), "test-plugin");
|
|
var context = new PluginLoadContext(pluginPath);
|
|
var assemblyName = new AssemblyName("NonExistentAssembly");
|
|
|
|
// Act
|
|
var assembly = context.LoadAssembly(assemblyName);
|
|
|
|
// Assert
|
|
Assert.Null(assembly);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsCollectible_ShouldBeTrue()
|
|
{
|
|
// Arrange
|
|
var pluginPath = Path.Combine(Path.GetTempPath(), "test-plugin");
|
|
var context = new PluginLoadContext(pluginPath);
|
|
|
|
// Assert
|
|
Assert.True(context.IsCollectible);
|
|
}
|
|
}
|