cs-codex-dist-tests/DistTestCore/Logs/CodexNodeLog.cs

36 lines
921 B
C#
Raw Normal View History

2023-04-13 09:30:19 +00:00
using Logging;
using NUnit.Framework;
2023-04-14 07:54:07 +00:00
namespace DistTestCore.Logs
2023-04-13 09:30:19 +00:00
{
public interface ICodexNodeLog
{
void AssertLogContains(string expectedString);
}
public class CodexNodeLog : ICodexNodeLog
{
private readonly LogFile logFile;
public CodexNodeLog(LogFile logFile)
{
this.logFile = logFile;
}
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-04-14 12:53:39 +00:00
Assert.Fail($"Unable to find string '{expectedString}' in CodexNode log file {logFile.FullFilename}");
2023-04-13 09:30:19 +00:00
}
}
}