public async Task SendPingAsyncWithHostAndTimeoutAndBufferAndPingOptions_Unix()
{
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
byte[] buffer = TestSettings.PayloadAsBytes;
await SendBatchPingAsync(
(ping) => ping.SendPingAsync(TestSettings.LocalHost, TestSettings.PingTimeout, buffer, new PingOptions()),
(pingReply) =>
{
Assert.Equal(IPStatus.Success, pingReply.Status);
Assert.True(pingReply.Address.Equals(localIpAddress));
// Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
if (Capability.CanUseRawSockets(localIpAddress.AddressFamily))
{
Assert.Equal(buffer, pingReply.Buffer);
}
else
{
Assert.Equal(Array.Empty<byte>(), pingReply.Buffer);
}
});
}