cs-codex-dist-tests/Tests/DistTestCore/DownloadedLogExtensions.cs

28 lines
861 B
C#
Raw Normal View History

2023-09-12 13:43:30 +00:00
using Core;
using NUnit.Framework;
namespace DistTestCore
{
public static class DownloadedLogExtensions
{
public static void AssertLogContains(this IDownloadedLog log, string expectedString)
{
2024-03-20 10:11:59 +00:00
Assert.That(log.GetLinesContaining(expectedString).Any(), $"Did not find '{expectedString}' in log.");
2023-09-12 13:43:30 +00:00
}
2023-12-15 08:32:03 +00:00
public static void AssertLogDoesNotContain(this IDownloadedLog log, params string[] unexpectedStrings)
{
2023-12-15 08:32:03 +00:00
var errors = new List<string>();
foreach (var str in unexpectedStrings)
{
2024-03-20 10:11:59 +00:00
var lines = log.GetLinesContaining(str);
foreach (var line in lines)
2023-12-15 08:32:03 +00:00
{
2024-03-20 10:11:59 +00:00
errors.Add($"Found '{str}' in line '{line}'.");
2023-12-15 08:32:03 +00:00
}
}
CollectionAssert.IsEmpty(errors);
}
2023-09-12 13:43:30 +00:00
}
}