mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 22:01:10 +00:00
- embeds the append-only historical and deny trust lists in the API and marks matching bundled plugins as Official without blocking loading - builds and records the current plugin manifest only for official release builds - deploys the PDF native libraries for the supported Linux, macOS and Windows runtimes from the plugin dependency manifest - records release hashes by appending only missing entries to master's manifest and rejects any diff that removes a line - documents the release flow, the supported runtimes and the plugin installer limits
85 lines
2.7 KiB
C#
85 lines
2.7 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using Nemera.Application.Common.DataAccess.Entities.Plugins;
|
|
using Nemera.Application.Common.Mapping.Plugins;
|
|
using Nemera.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
|
using Nemera.Contracts.Responses.Plugins;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.Json;
|
|
#endregion
|
|
|
|
namespace Nemera.Application.UnitTests.Common.Mapping.Plugins;
|
|
|
|
/// <summary>
|
|
/// Contains unit tests for the <see cref="PluginEntityMapping"/> class.
|
|
/// </summary>
|
|
[ExcludeFromCodeCoverage]
|
|
public class PluginEntityMappingTests
|
|
{
|
|
private readonly PluginEntityFixture _pluginEntityFixture = new();
|
|
|
|
[Fact]
|
|
public void ToResponse_WhenMappingValidPluginEntity_ShouldMapCorrectly()
|
|
{
|
|
// Arrange
|
|
PluginEntity entity = _pluginEntityFixture.Create();
|
|
IReadOnlyDictionary<string, string>? expectedSettings = JsonSerializer.Deserialize<Dictionary<string, string>>(entity.SettingsJson!);
|
|
|
|
// Act
|
|
PluginResponse result = entity.ToResponse(isOfficial: true);
|
|
|
|
// Assert
|
|
Assert.NotNull(result);
|
|
Assert.Equal(entity.Id, result.Id);
|
|
Assert.Equal(entity.Name, result.Name);
|
|
Assert.Equal(entity.Author, result.Author);
|
|
Assert.Equal(entity.Version, result.Version);
|
|
Assert.Equal(entity.Description, result.Description);
|
|
Assert.Equal(entity.LoadStatus, result.LoadStatus);
|
|
Assert.Equal(entity.LoadError, result.LoadError);
|
|
Assert.Equal(expectedSettings, result.Settings);
|
|
Assert.True(result.IsOfficial);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToResponse_WhenPluginIsNotOfficial_ShouldSetIsOfficialFalse()
|
|
{
|
|
// Arrange
|
|
PluginEntity entity = _pluginEntityFixture.Create();
|
|
|
|
// Act
|
|
PluginResponse result = entity.ToResponse(isOfficial: false);
|
|
|
|
// Assert
|
|
Assert.False(result.IsOfficial);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToSettings_WhenSettingsAreStored_ShouldDeserializeThem()
|
|
{
|
|
// Arrange
|
|
PluginEntity entity = _pluginEntityFixture.Create();
|
|
|
|
// Act
|
|
IReadOnlyDictionary<string, string>? result = entity.ToSettings();
|
|
|
|
// Assert
|
|
Assert.NotNull(result);
|
|
Assert.NotEmpty(result);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToSettings_WhenNoSettingsAreStored_ShouldReturnNull()
|
|
{
|
|
// Arrange
|
|
PluginEntity entity = _pluginEntityFixture.Create();
|
|
entity.SettingsJson = null;
|
|
|
|
// Act
|
|
IReadOnlyDictionary<string, string>? result = entity.ToSettings();
|
|
|
|
// Assert
|
|
Assert.Null(result);
|
|
}
|
|
}
|