mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-22 17:24:27 +08:00
changed.更了好多
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using LanMountainDesktop.Launcher.Services;
|
||||
using LanMountainDesktop.Shared.Contracts.Launcher;
|
||||
using Xunit;
|
||||
|
||||
namespace LanMountainDesktop.Tests;
|
||||
@@ -88,4 +89,54 @@ public sealed class HostAppSettingsOobeMergerTests
|
||||
Directory.Delete(dir, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("RestartApp", MultiInstanceLaunchBehavior.RestartApp)]
|
||||
[InlineData("OpenDesktopSilently", MultiInstanceLaunchBehavior.OpenDesktopSilently)]
|
||||
[InlineData("PromptOnly", MultiInstanceLaunchBehavior.PromptOnly)]
|
||||
[InlineData("NotifyAndOpenDesktop", MultiInstanceLaunchBehavior.NotifyAndOpenDesktop)]
|
||||
public void LoadMultiInstanceLaunchBehavior_ReadsStringValues(
|
||||
string value,
|
||||
MultiInstanceLaunchBehavior expected)
|
||||
{
|
||||
var dir = Path.Combine(Path.GetTempPath(), "LMD.MultiInstanceSettings", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(dir);
|
||||
var path = Path.Combine(dir, "settings.json");
|
||||
File.WriteAllText(path, $$"""
|
||||
{
|
||||
"MultiInstanceLaunchBehavior": "{{value}}"
|
||||
}
|
||||
""");
|
||||
|
||||
try
|
||||
{
|
||||
Assert.Equal(expected, HostAppSettingsOobeMerger.LoadMultiInstanceLaunchBehavior(path));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(dir, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("{}")]
|
||||
[InlineData("{ \"MultiInstanceLaunchBehavior\": \"Unknown\" }")]
|
||||
public void LoadMultiInstanceLaunchBehavior_FallsBackToNotifyAndOpenDesktop(string json)
|
||||
{
|
||||
var dir = Path.Combine(Path.GetTempPath(), "LMD.MultiInstanceSettings", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(dir);
|
||||
var path = Path.Combine(dir, "settings.json");
|
||||
File.WriteAllText(path, json);
|
||||
|
||||
try
|
||||
{
|
||||
Assert.Equal(
|
||||
MultiInstanceLaunchBehavior.NotifyAndOpenDesktop,
|
||||
HostAppSettingsOobeMerger.LoadMultiInstanceLaunchBehavior(path));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(dir, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user