Files
LanMountainDesktop/tests/LanMountainDesktop.Tests/AirAppManifestRuntimeTests.cs

49 lines
1.5 KiB
C#
Raw Normal View History

using System.Text;
2026-08-11 23:03:55 +08:00
using LanMountainDesktop.AirAppSdk;
using Xunit;
namespace LanMountainDesktop.Tests;
2026-08-11 23:03:55 +08:00
public sealed class AirAppManifestRuntimeTests
{
[Fact]
public void Load_WhenRuntimeIsMissing_DefaultsToInProcess()
{
const string json = """
{
"id": "plugin.runtime.default",
"name": "Runtime Default",
2026-08-11 23:03:55 +08:00
"entranceAssembly": "AirApp.dll"
}
""";
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(json));
2026-08-11 23:03:55 +08:00
var manifest = LanMountainDesktop.AirAppSdk.AirAppManifest.Load(stream, "airapp.json");
Assert.NotNull(manifest.Runtime);
2026-08-11 23:03:55 +08:00
Assert.Equal(AirAppRuntimeModes.InProcess, manifest.Runtime!.Mode);
Assert.Equal(AirAppRuntimeMode.InProcess, manifest.RuntimeMode);
}
[Fact]
public void Load_WhenRuntimeModeIsInvalid_ThrowsHelpfulError()
{
const string json = """
{
"id": "plugin.runtime.invalid",
"name": "Runtime Invalid",
2026-08-11 23:03:55 +08:00
"entranceAssembly": "AirApp.dll",
"runtime": {
"mode": "shared-worker"
}
}
""";
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(json));
2026-08-11 23:03:55 +08:00
var ex = Assert.Throws<InvalidOperationException>(() => LanMountainDesktop.AirAppSdk.AirAppManifest.Load(stream, "airapp.json"));
Assert.Contains("runtime.mode", ex.Message);
Assert.Contains("shared-worker", ex.Message);
}
}