Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed GetNetworkInterfaces method to to retrieve information related to all interfaces #100824

Merged
merged 8 commits into from
Apr 20, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ internal static unsafe NetworkInterface[] GetNetworkInterfaces()
List<SystemNetworkInterface> interfaceList = new List<SystemNetworkInterface>();

Interop.IpHlpApi.GetAdaptersAddressesFlags flags =
Interop.IpHlpApi.GetAdaptersAddressesFlags.IncludeGateways
| Interop.IpHlpApi.GetAdaptersAddressesFlags.IncludeWins;
Interop.IpHlpApi.GetAdaptersAddressesFlags.IncludeAllInterfaces;

// Figure out the right buffer size for the adapter information.
uint result = Interop.IpHlpApi.GetAdaptersAddresses(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public NetworkInterfaceBasicTest(ITestOutputHelper output)
[Fact]
public void BasicTest_GetNetworkInterfaces_AtLeastOne()
{

Assert.NotEqual<int>(0, NetworkInterface.GetAllNetworkInterfaces().Length);
}

Expand Down Expand Up @@ -50,7 +51,8 @@ public void BasicTest_AccessInstanceProperties_NoExceptions()

if (nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
Assert.Equal(6, nic.GetPhysicalAddress().GetAddressBytes().Length);
var physicalAddressLength = nic.GetPhysicalAddress().GetAddressBytes().Length;
Assert.True(physicalAddressLength == 0 || physicalAddressLength == 6);
}
}
}
Expand Down
Loading