feat(01-05): add Serilog integration tests and App.xaml.cs LogPanelSink comment
- LoggingIntegrationTests: verifies Serilog writes rolling log file with correct content - LogPanelSink structural smoke test: confirms type implements ILogEventSink - App.xaml.cs: added comment for LogPanelSink DI registration deferred to plan 01-06
This commit is contained in:
@@ -1,7 +1,47 @@
|
|||||||
|
using Serilog;
|
||||||
|
using Serilog.Core;
|
||||||
|
using SharepointToolbox.Infrastructure.Logging;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace SharepointToolbox.Tests.Integration;
|
namespace SharepointToolbox.Tests.Integration;
|
||||||
|
|
||||||
public class LoggingIntegrationTests
|
[Trait("Category", "Integration")]
|
||||||
|
public class LoggingIntegrationTests : IDisposable
|
||||||
{
|
{
|
||||||
[Fact(Skip = "Wave 0 stub — implemented in plan 01-05")]
|
private readonly string _tempLogDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||||
public void Serilog_WritesTo_RollingFile_On_Startup() { }
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Serilog_WritesLogFile_WhenMessageLogged()
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_tempLogDir);
|
||||||
|
var logFile = Path.Combine(_tempLogDir, "test-.log");
|
||||||
|
|
||||||
|
var logger = new LoggerConfiguration()
|
||||||
|
.WriteTo.File(logFile, rollingInterval: RollingInterval.Day)
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
|
logger.Information("Test log message {Value}", 42);
|
||||||
|
await logger.DisposeAsync();
|
||||||
|
|
||||||
|
var files = Directory.GetFiles(_tempLogDir, "*.log");
|
||||||
|
Assert.Single(files);
|
||||||
|
var content = await File.ReadAllTextAsync(files[0]);
|
||||||
|
Assert.Contains("Test log message 42", content);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void LogPanelSink_CanBeInstantiated_WithRichTextBox()
|
||||||
|
{
|
||||||
|
// Verify the sink type instantiates without throwing
|
||||||
|
// Cannot test actual UI writes without STA thread — this is structural smoke only
|
||||||
|
var sinkType = typeof(LogPanelSink);
|
||||||
|
Assert.NotNull(sinkType);
|
||||||
|
Assert.True(typeof(ILogEventSink).IsAssignableFrom(sinkType));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(_tempLogDir))
|
||||||
|
Directory.Delete(_tempLogDir, recursive: true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,5 +36,7 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
// Placeholder — services registered in subsequent plans
|
// Placeholder — services registered in subsequent plans
|
||||||
services.AddSingleton<MainWindow>();
|
services.AddSingleton<MainWindow>();
|
||||||
|
// LogPanelSink registered in plan 01-06 after MainWindow is created
|
||||||
|
// (requires RichTextBox reference from MainWindow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user