cs-codex-dist-tests/Tests/ExperimentalTests/MetricsAccessExtensions.cs

23 lines
722 B
C#
Raw Normal View History

2023-09-13 09:59:21 +00:00
using DistTestCore.Helpers;
using Logging;
using MetricsPlugin;
using NUnit.Framework.Constraints;
namespace CodexTests
2023-09-13 09:59:21 +00:00
{
public static class MetricsAccessExtensions
{
public static void AssertThat(this IMetricsAccess access, string metricName, IResolveConstraint constraint, ILog? log = null, string message = "")
{
AssertHelpers.RetryAssert(constraint, () =>
{
var metricSet = access.GetMetric(metricName);
var metricValue = metricSet.Values[0].Value;
if (log != null) log.Log($"{access.TargetName} metric '{metricName}' = {metricValue}");
return metricValue;
}, message);
}
}
}