2023-03-26 08:45:01 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
namespace CodexDistTestCore
|
|
|
|
|
{
|
2023-03-31 08:00:44 +00:00
|
|
|
|
public interface ICodexNodeLog
|
|
|
|
|
{
|
|
|
|
|
void AssertLogContains(string expectedString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CodexNodeLog : ICodexNodeLog
|
2023-03-26 08:45:01 +00:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.Fail($"Unable to find string '{expectedString}' in CodexNode log file {logFile.FilenameWithoutPath}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|