Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 600c6a3

Browse files
committed
Merge pull request #2792 from pgavlin/FixSocketAddressPalTest
Fix a SocketAddressPal test.
2 parents 0268cb8 + 1fc747d commit 600c6a3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/System.Net.Primitives/tests/PalTests/SocketAddressPalTest.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,19 @@ public void Port_Get_Set_IPv6(ushort port)
6161
}
6262

6363
[Fact]
64-
public void Port_Get_Set_Throws()
64+
public void Port_Get_Set_Throws_IPv4()
6565
{
66-
var buffer = new byte[1];
66+
var buffer = new byte[2];
67+
SocketAddressPal.SetAddressFamily(buffer, AddressFamily.InterNetwork);
68+
Assert.ThrowsAny<Exception>(() => SocketAddressPal.SetPort(buffer, 0));
69+
Assert.ThrowsAny<Exception>(() => SocketAddressPal.GetPort(buffer));
70+
}
71+
72+
[Fact]
73+
public void Port_Get_Set_Throws_IPv6()
74+
{
75+
var buffer = new byte[2];
76+
SocketAddressPal.SetAddressFamily(buffer, AddressFamily.InterNetworkV6);
6777
Assert.ThrowsAny<Exception>(() => SocketAddressPal.SetPort(buffer, 0));
6878
Assert.ThrowsAny<Exception>(() => SocketAddressPal.GetPort(buffer));
6979
}

0 commit comments

Comments
 (0)