Skip to content

Commit cb195ec

Browse files
committed
Updated logger to use event instead of action property
1 parent a73a64b commit cb195ec

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/EventLogExpert.UI.Tests/Services/DebugLogServiceTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,22 @@ public void Constructor_WhenLogLevelIsTrace_ShouldEnableFirstChanceExceptionLogg
147147
}
148148

149149
[Fact]
150-
public void DebugLogLoaded_WhenSet_ShouldBeRetrievable()
150+
public void DebugLogLoaded_WhenSubscribed_ShouldBeInvocable()
151151
{
152152
// Arrange
153153
var fileLocationOptions = new FileLocationOptions(_testDirectory);
154154
var mockSettingsService = CreateMockSettingsService(LogLevel.Information);
155155

156156
using var debugLogService = new DebugLogService(fileLocationOptions, mockSettingsService);
157157

158-
Action testAction = () => { };
158+
var wasInvoked = false;
159+
debugLogService.DebugLogLoaded += () => wasInvoked = true;
159160

160161
// Act
161-
debugLogService.DebugLogLoaded = testAction;
162+
debugLogService.LoadDebugLog();
162163

163164
// Assert
164-
Assert.Same(testAction, debugLogService.DebugLogLoaded);
165+
Assert.True(wasInvoked);
165166
}
166167

167168
public void Dispose()
@@ -234,22 +235,21 @@ public async Task LoadAsync_WhenLogFileIsEmpty_ShouldReturnNoLines()
234235
}
235236

236237
[Fact]
237-
public void LoadDebugLog_WhenDebugLogLoadedIsNull_ShouldNotThrow()
238+
public void LoadDebugLog_WhenNoSubscribers_ShouldNotThrow()
238239
{
239240
// Arrange
240241
var fileLocationOptions = new FileLocationOptions(_testDirectory);
241242
var mockSettingsService = CreateMockSettingsService(LogLevel.Information);
242243

243244
using var debugLogService = new DebugLogService(fileLocationOptions, mockSettingsService);
244-
debugLogService.DebugLogLoaded = null;
245245

246-
// Act & Assert
246+
// Act & Assert - no subscribers attached
247247
var exception = Record.Exception(() => debugLogService.LoadDebugLog());
248248
Assert.Null(exception);
249249
}
250250

251251
[Fact]
252-
public void LoadDebugLog_WhenDebugLogLoadedIsSet_ShouldInvokeAction()
252+
public void LoadDebugLog_WhenSubscribed_ShouldInvokeHandler()
253253
{
254254
// Arrange
255255
var fileLocationOptions = new FileLocationOptions(_testDirectory);
@@ -258,7 +258,7 @@ public void LoadDebugLog_WhenDebugLogLoadedIsSet_ShouldInvokeAction()
258258
using var debugLogService = new DebugLogService(fileLocationOptions, mockSettingsService);
259259

260260
var actionInvoked = false;
261-
debugLogService.DebugLogLoaded = () => actionInvoked = true;
261+
debugLogService.DebugLogLoaded += () => actionInvoked = true;
262262

263263
// Act
264264
debugLogService.LoadDebugLog();

src/EventLogExpert.UI/Interfaces/IFileLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace EventLogExpert.UI.Interfaces;
77

88
public interface IFileLogger
99
{
10-
Action? DebugLogLoaded { get; set; }
10+
event Action? DebugLogLoaded;
1111

1212
Task ClearAsync();
1313

src/EventLogExpert.UI/Services/DebugLogService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public DebugLogService(FileLocationOptions fileLocationOptions, ISettingsService
3434
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
3535
}
3636

37-
public Action? DebugLogLoaded { get; set; }
37+
public event Action? DebugLogLoaded;
3838

3939
public async Task ClearAsync()
4040
{

0 commit comments

Comments
 (0)