[tests] Simplify NWPathTest.EnumerateGatewayTest (#20853)

* Remove code to test NWPath.EnumerateInterfaces, because this method is already tested elsewhere.
* Assume that if the test fails to find any gateways, it might be because the
  current machine doesn't have any (which happens on one of my machines), and
  in that case ignore the test.
This commit is contained in:
Rolf Bjarne Kvinge 2024-07-10 21:40:50 +02:00 коммит произвёл GitHub
Родитель b3fc0d93ec
Коммит 4fd259d4dc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 3 добавлений и 9 удалений

Просмотреть файл

@ -170,27 +170,21 @@ namespace MonoTouchFixtures.Network {
public void EnumerateGatewayTest ()
{
var e1 = new TaskCompletionSource<bool> ();
var e2 = new TaskCompletionSource<bool> ();
var monitor = new NWPathMonitor ();
try {
monitor.SetQueue (DispatchQueue.DefaultGlobalQueue);
monitor.Start ();
monitor.SnapshotHandler += path => {
path.EnumerateGateways (gateway => {
e1.TrySetResult (true);
return true;
});
path.EnumerateInterfaces (@interface => {
e2.TrySetResult (true);
return true;
});
};
monitor.Start ();
var rv = TestRuntime.RunAsync (TimeSpan.FromSeconds (5),
Task.CompletedTask,
Task.WhenAll (e1.Task, e2.Task));
e1.Task);
if (!rv)
TestRuntime.IgnoreInCI ("This test doesn't seem to be working on the bots, uncommon network setup?");
Assert.Ignore ("No gateways on this machine?"); // no gateways isn't all that uncommon, so just always ignore in this case.
Assert.IsTrue (rv, "Called back");
} finally {
monitor.Cancel ();