Skip to content

Commit 5c62b93

Browse files
committed
Changed large sting allocation for file test
1 parent 8421de7 commit 5c62b93

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ public void Constructor_WhenLogFileTooLarge_ShouldDeleteExistingFile()
8282
var fileLocationOptions = new FileLocationOptions(_testDirectory);
8383
var mockSettingsService = CreateMockSettingsService(LogLevel.Information);
8484

85-
// Create a file larger than 10MB (MaxLogSize)
86-
var largeContent = new string('x', 11 * 1024 * 1024);
87-
File.WriteAllText(_testLogPath, largeContent);
85+
// Create a file larger than 10MB (MaxLogSize) without allocating a large string
86+
using (var fs = new FileStream(_testLogPath, FileMode.Create, FileAccess.Write))
87+
{
88+
fs.SetLength(11 * 1024 * 1024);
89+
}
8890

8991
// Act
9092
using var debugLogService = new DebugLogService(fileLocationOptions, mockSettingsService);

src/EventLogExpert.UI/Services/DebugLogService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using EventLogExpert.UI.Interfaces;
66
using EventLogExpert.UI.Options;
77
using Microsoft.Extensions.Logging;
8+
using System.Diagnostics;
89
using System.Runtime.ExceptionServices;
910

1011
namespace EventLogExpert.UI.Services;

0 commit comments

Comments
 (0)