Skip to content

Commit 85789c5

Browse files
author
BRUNER Patrick
committed
menutoolbarcontroller
1 parent b32ff0e commit 85789c5

24 files changed

Lines changed: 565 additions & 261 deletions

src/LogExpert.Configuration/ConfigManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,22 @@ public void AddToFileHistory (string fileName)
281281
Save(SettingsFlags.FileHistory);
282282
}
283283

284+
[SupportedOSPlatform("windows")]
285+
public void RemoveFromFileHistory (string fileName)
286+
{
287+
bool findName (string s) => s.ToUpperInvariant().Equals(fileName.ToUpperInvariant(), StringComparison.Ordinal);
288+
289+
var index = Instance.Settings.FileHistoryList.FindIndex(findName);
290+
291+
if (index != -1)
292+
{
293+
Instance.Settings.FileHistoryList.RemoveAt(index);
294+
}
295+
296+
Save(SettingsFlags.FileHistory);
297+
}
298+
299+
284300
public void ClearLastOpenFilesList ()
285301
{
286302
lock (_loadSaveLock)

src/LogExpert.Core/Interface/IConfigManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ public interface IConfigManager
151151
/// This method is supported only on Windows platforms.</remarks>
152152
/// <param name="fileName">The name of the file to add to the file history list. Comparison is case-insensitive.</param>
153153
void AddToFileHistory (string fileName);
154+
155+
/// <summary>
156+
/// Removes the specified file name from the file history list.
157+
/// </summary>
158+
/// <param name="fileName">The name of the file to remove from the file history list. Comparison is case-insensitive.</param>
159+
void RemoveFromFileHistory (string fileName);
154160

155161
/// <summary>
156162
/// Clears the list of recently opened files.

src/LogExpert.Tests/Services/LedIndicatorServiceTests.cs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Runtime.Versioning;
22

3-
using LogExpert.UI.Services;
3+
using LogExpert.UI.Interface.Services;
4+
using LogExpert.UI.Services.LedService;
45

56
using NUnit.Framework;
67

@@ -9,11 +10,12 @@ namespace LogExpert.Tests.Services;
910
[TestFixture]
1011
[Apartment(ApartmentState.STA)] // Required for UI components
1112
[SupportedOSPlatform("windows")]
12-
public class LedIndicatorServiceTests
13+
public class LedIndicatorServiceTests : IDisposable
1314
{
1415
private LedIndicatorService? _service;
1516
private ApplicationContext? _appContext;
1617
private WindowsFormsSynchronizationContext? _syncContext;
18+
private bool _disposed;
1719

1820
[SetUp]
1921
public void Setup ()
@@ -140,9 +142,9 @@ public void StartStop_DoesNotThrowException ()
140142
_service!.Initialize(Color.Blue);
141143

142144
// Act
143-
_service.Start();
145+
_service.StartService();
144146
Thread.Sleep(500); // Let timer tick a few times
145-
_service.Stop();
147+
_service.StopService();
146148

147149
// Assert - no exception
148150
Assert.That(true, Is.True, "Service started and stopped without exceptions");
@@ -192,7 +194,7 @@ public void Dispose_DisposesAllResources ()
192194
{
193195
// Arrange
194196
_service!.Initialize(Color.Blue);
195-
_service.Start();
197+
_service.StartService();
196198

197199
// Act
198200
_service.Dispose();
@@ -217,7 +219,7 @@ public void Start_WithoutInitialize_ThrowsException ()
217219
// Arrange - don't initialize
218220

219221
// Act & Assert
220-
_ = Assert.Throws<InvalidOperationException>(() => _service!.Start());
222+
_ = Assert.Throws<InvalidOperationException>(() => _service!.StartService());
221223
}
222224

223225
[Test]
@@ -316,4 +318,25 @@ public void GetIcon_WithSyncedState_ReturnsSyncedIcon ()
316318
// The icons should be different (synced has blue indicator on left side)
317319
Assert.That(iconSynced, Is.Not.EqualTo(iconNotSynced));
318320
}
321+
322+
public void Dispose ()
323+
{
324+
Dispose(true);
325+
GC.SuppressFinalize(this);
326+
}
327+
328+
protected virtual void Dispose (bool disposing)
329+
{
330+
if (_disposed)
331+
{
332+
return;
333+
}
334+
335+
if (disposing)
336+
{
337+
_service?.Dispose();
338+
}
339+
340+
_disposed = true;
341+
}
319342
}

0 commit comments

Comments
 (0)