Skip to content

Commit 0b5090a

Browse files
committed
Cover read-only
1 parent 6052b0b commit 0b5090a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libraries/System.Net.Primitives/tests/FunctionalTests/IPAddressTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,15 @@ public static void Address_ThrowsIPv6SpecificMessage()
369369
Assert.Equal((int)SocketError.OperationNotSupported, ex.ErrorCode);
370370
Assert.Contains($"'{ip.AddressFamily}' {nameof(AddressFamily)}.", ex.Message);
371371
}
372+
373+
[Fact]
374+
public static void Address_ReadOnlyStatic_ThrowsReadOnlyException()
375+
{
376+
var readOnlyIp = IPAddress.Loopback;
377+
var ex = Assert.Throws<SocketException>(() => readOnlyIp.Address = 0x0A000001L);
378+
Assert.Equal((int)SocketError.OperationNotSupported, ex.ErrorCode);
379+
Assert.Contains("read-only", ex.Message);
380+
}
372381
#pragma warning restore 618
373382
}
374383
}

0 commit comments

Comments
 (0)