Keep official clients in charge of sync while Explorer can group locations, persist UI prefs, and list zip/rar/7z members without extracting them. Co-authored-by: Cursor <cursoragent@cursor.com>
70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using Explorer.Application;
|
|
using Explorer.Domain.Abstractions;
|
|
|
|
namespace Explorer.Application.Tests;
|
|
|
|
public class UiPreferencesStoreTests
|
|
{
|
|
[Fact]
|
|
public void Parse_reads_theme_and_independent_group_flags()
|
|
{
|
|
var prefs = UiPreferencesStore.Parse(
|
|
[
|
|
"theme=Light",
|
|
"group-network=true",
|
|
"group-cloud=false",
|
|
"index-archives=true"
|
|
]);
|
|
Assert.Equal("Light", prefs.Theme);
|
|
Assert.True(prefs.GroupNetworkPlaces);
|
|
Assert.False(prefs.GroupCloudPlaces);
|
|
Assert.True(prefs.IndexArchiveContents);
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_defaults_missing_keys()
|
|
{
|
|
var prefs = UiPreferencesStore.Parse(["theme=dark"]);
|
|
Assert.Equal("Dark", prefs.Theme);
|
|
Assert.False(prefs.GroupNetworkPlaces);
|
|
Assert.False(prefs.GroupCloudPlaces);
|
|
Assert.False(prefs.IndexArchiveContents);
|
|
}
|
|
|
|
[Fact]
|
|
public void Load_and_save_roundtrip()
|
|
{
|
|
var dir = Path.Combine(Path.GetTempPath(), "ew-ui-prefs", Guid.NewGuid().ToString("N"));
|
|
try
|
|
{
|
|
var store = new UiPreferencesStore(new PrefsEnv(dir));
|
|
store.Save(new UiPreferences("Light", true, false, true));
|
|
var loaded = store.Load();
|
|
Assert.Equal("Light", loaded.Theme);
|
|
Assert.True(loaded.GroupNetworkPlaces);
|
|
Assert.False(loaded.GroupCloudPlaces);
|
|
Assert.True(loaded.IndexArchiveContents);
|
|
}
|
|
finally
|
|
{
|
|
try { Directory.Delete(dir, true); } catch { /* ignore */ }
|
|
}
|
|
}
|
|
}
|
|
|
|
file sealed class PrefsEnv : IAppEnvironment
|
|
{
|
|
public PrefsEnv(string dir)
|
|
{
|
|
DataDirectory = dir;
|
|
Directory.CreateDirectory(dir);
|
|
DatabasePath = Path.Combine(dir, "index.db");
|
|
LogDirectory = Path.Combine(dir, "logs");
|
|
Directory.CreateDirectory(LogDirectory);
|
|
}
|
|
|
|
public string DataDirectory { get; }
|
|
public string DatabasePath { get; }
|
|
public string LogDirectory { get; }
|
|
}
|