mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
36 lines
971 B
C#
36 lines
971 B
C#
|
|
using LanMountainDesktop.Launcher.Models;
|
||
|
|
using Xunit;
|
||
|
|
|
||
|
|
namespace LanMountainDesktop.Tests;
|
||
|
|
|
||
|
|
public sealed class DataLocationResolverTests : IDisposable
|
||
|
|
{
|
||
|
|
private readonly string _appRoot = Path.Combine(
|
||
|
|
Path.GetTempPath(),
|
||
|
|
"LanMountainDesktop.Tests",
|
||
|
|
nameof(DataLocationResolverTests),
|
||
|
|
Guid.NewGuid().ToString("N"));
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void ApplyLocationChoice_PortableWithoutCustomPath_UsesAppRootDesktopDirectory()
|
||
|
|
{
|
||
|
|
Directory.CreateDirectory(_appRoot);
|
||
|
|
var resolver = new DataLocationResolver(_appRoot);
|
||
|
|
|
||
|
|
var applied = resolver.ApplyLocationChoice(DataLocationMode.Portable);
|
||
|
|
|
||
|
|
Assert.True(applied);
|
||
|
|
Assert.Equal(
|
||
|
|
Path.Combine(Path.GetFullPath(_appRoot), "Desktop"),
|
||
|
|
resolver.ResolveDataRoot());
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Dispose()
|
||
|
|
{
|
||
|
|
if (Directory.Exists(_appRoot))
|
||
|
|
{
|
||
|
|
Directory.Delete(_appRoot, recursive: true);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|