2
0
mirror of synced 2025-01-12 17:44:08 +00:00

38 lines
1018 B
C#
Raw Normal View History

2023-04-13 11:30:19 +02:00
using Logging;
using NUnit.Framework;
2023-04-14 09:54:07 +02:00
namespace DistTestCore.Logs
2023-04-13 11:30:19 +02:00
{
2023-06-27 15:28:00 +02:00
public interface IDownloadedLog
2023-04-13 11:30:19 +02:00
{
void AssertLogContains(string expectedString);
}
2023-06-27 15:28:00 +02:00
public class DownloadedLog : IDownloadedLog
2023-04-13 11:30:19 +02:00
{
private readonly LogFile logFile;
2023-06-27 15:28:00 +02:00
private readonly string owner;
2023-04-13 11:30:19 +02:00
2023-06-27 15:28:00 +02:00
public DownloadedLog(LogFile logFile, string owner)
2023-04-13 11:30:19 +02:00
{
this.logFile = logFile;
this.owner = owner;
2023-04-13 11:30:19 +02:00
}
public void AssertLogContains(string expectedString)
{
using var file = File.OpenRead(logFile.FullFilename);
using var streamReader = new StreamReader(file);
var line = streamReader.ReadLine();
while (line != null)
{
if (line.Contains(expectedString)) return;
line = streamReader.ReadLine();
}
2023-06-27 15:28:00 +02:00
Assert.Fail($"{owner} Unable to find string '{expectedString}' in CodexNode log file {logFile.FullFilename}");
2023-04-13 11:30:19 +02:00
}
}
}