using Microsoft.Extensions.Logging.Abstractions; using Moli.Desktop.Configuration; using Moli.Desktop.Diagnostics; using Moli.Desktop.Host; using Moli.Desktop.Plugins; namespace Moli.Desktop.Tests.Host; public class DefaultContentInstallerTests { [Fact] public async Task InstallAsync_CopiesSamplesAndSeedsRegistryAndLayouts() { var root = Path.Combine(Path.GetTempPath(), "Moli.Desktop.Tests", Guid.NewGuid().ToString("N")); var paths = new DesktopPaths(Path.Combine(root, "app"), Path.Combine(root, "local")); var diagnostics = new DiagnosticsService(paths, NullLogger.Instance); var configuration = new JsonConfigurationService(paths, diagnostics); var installer = new DefaultContentInstaller(paths, configuration, diagnostics); await installer.InstallAsync(); Assert.True(File.Exists(Path.Combine(paths.PluginDirectory, "sample.wallpaper", "plugin.json"))); Assert.True(File.Exists(Path.Combine(paths.PluginDirectory, "sample.clock", "index.html"))); Assert.True(File.Exists(Path.Combine(paths.PluginDirectory, "sample.system-info", "index.html"))); var registry = await configuration.LoadPluginRegistryAsync(); Assert.Contains(registry.Plugins, item => item.Id == new PluginId("sample.wallpaper") && item.State == PluginState.Enabled); Assert.Contains(registry.Plugins, item => item.Id == new PluginId("sample.clock") && item.State == PluginState.Enabled); Assert.Contains(registry.Plugins, item => item.Id == new PluginId("sample.system-info") && item.State == PluginState.Enabled); var layout = await configuration.LoadLayoutAsync(); Assert.Contains(layout.Instances, item => item.PluginId == new PluginId("sample.clock")); Assert.Contains(layout.Instances, item => item.PluginId == new PluginId("sample.system-info")); Assert.DoesNotContain(layout.Instances, item => item.PluginId == new PluginId("sample.wallpaper")); } }