// Copyright 2020-2025 The NATS Authors
// Licensed under the Apache License, Version 2.0
namespace ZB.MOM.NatsNet.Server.IntegrationTests.Helpers;
///
/// Polling / assertion helpers ported from the Go test framework's checkFor and
/// related utilities.
///
public static class CheckHelper
{
///
/// Polls every until it
/// returns null (success) or expires.
///
public static void CheckFor(
TimeSpan timeout,
TimeSpan interval,
Func check)
{
var deadline = DateTime.UtcNow + timeout;
string? last = null;
while (DateTime.UtcNow < deadline)
{
last = check();
if (last is null)
return;
Thread.Sleep(interval);
}
throw new Xunit.Sdk.XunitException($"CheckFor timed out after {timeout}: {last}");
}
///
/// Waits until the supplied server reports exactly
/// leaf-node connections.
///
public static void CheckLeafNodeConnectedCount(object server, int expected) =>
throw new NotImplementedException("Requires a running server instance.");
}