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"));
|
}
|
}
|