27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
using GatewayKeepalive.Windows;
|
|
|
|
namespace GatewayKeepalive.Tests;
|
|
|
|
internal static class NativeLayoutTests
|
|
{
|
|
public static Task X64LayoutAsync()
|
|
{
|
|
Check.Equal(8, IntPtr.Size, "Native layout assertions require the x64 test host");
|
|
var layout = WindowsNetworkBackend.NativeLayout();
|
|
var properties = layout.GetType().GetProperties().ToDictionary(property => property.Name, property => property.GetValue(layout));
|
|
|
|
int Read(string name)
|
|
{
|
|
Check.True(properties.TryGetValue(name, out var value), $"NativeLayout should expose {name}");
|
|
return (int)value!;
|
|
}
|
|
|
|
Check.Equal(104, Read("RouteSize"), "MIB_IPFORWARD_ROW2 x64 size");
|
|
Check.Equal(168, Read("InterfaceSize"), "MIB_IPINTERFACE_ROW x64 size");
|
|
Check.Equal(64, Read("DnsSize"), "DNS_SETTINGS x64 size");
|
|
Check.Equal(84, Read("RouteMetricOffset"), "MIB_IPFORWARD_ROW2 metric offset");
|
|
Check.Equal(148, Read("InterfaceMetricOffset"), "MIB_IPINTERFACE_ROW metric offset");
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|