diff --git a/SharepointToolbox.Tests/Integration/LoggingIntegrationTests.cs b/SharepointToolbox.Tests/Integration/LoggingIntegrationTests.cs index f0f07b9..47be6af 100644 --- a/SharepointToolbox.Tests/Integration/LoggingIntegrationTests.cs +++ b/SharepointToolbox.Tests/Integration/LoggingIntegrationTests.cs @@ -1,7 +1,47 @@ +using Serilog; +using Serilog.Core; +using SharepointToolbox.Infrastructure.Logging; +using System.IO; + namespace SharepointToolbox.Tests.Integration; -public class LoggingIntegrationTests +[Trait("Category", "Integration")] +public class LoggingIntegrationTests : IDisposable { - [Fact(Skip = "Wave 0 stub — implemented in plan 01-05")] - public void Serilog_WritesTo_RollingFile_On_Startup() { } + private readonly string _tempLogDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + + [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); + } } diff --git a/SharepointToolbox/App.xaml.cs b/SharepointToolbox/App.xaml.cs index ad241e0..3bfe562 100644 --- a/SharepointToolbox/App.xaml.cs +++ b/SharepointToolbox/App.xaml.cs @@ -36,5 +36,7 @@ public partial class App : Application { // Placeholder — services registered in subsequent plans services.AddSingleton(); + // LogPanelSink registered in plan 01-06 after MainWindow is created + // (requires RichTextBox reference from MainWindow) } }