基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-05-03 c3a5f58e60f85400edfb5f5379145390316394c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using Microsoft.Extensions.Logging.Abstractions;
using Moli.Desktop.Diagnostics;
using Moli.Desktop.Host;
 
namespace Moli.Desktop.Tests.Diagnostics;
 
public class DiagnosticsServiceTests
{
    [Fact]
    public void Record_CreatesLogDirectoryAndSnapshot()
    {
        var root = CreateTempRoot();
        var paths = new DesktopPaths(Path.Combine(root, "app"), Path.Combine(root, "local"));
        var service = new DiagnosticsService(paths, NullLogger<DiagnosticsService>.Instance);
 
        service.Record(DiagnosticSeverity.Warning, "TestWarning", "Something happened.");
 
        Assert.True(Directory.Exists(paths.LogDirectory));
        Assert.Contains(service.Snapshot(), entry => entry.Code == "TestWarning");
    }
 
    private static string CreateTempRoot()
    {
        return Path.Combine(Path.GetTempPath(), "Moli.Desktop.Tests", Guid.NewGuid().ToString("N"));
    }
}