@@ -388,6 +388,94 @@ private static System.Collections.IEnumerable YieldTestCases_Equals_OfIPAddress(
388
388
public void Equals_OfIPAddress ( AddressTableEntry entry , IPAddress ? ipAddress , bool expected )
389
389
=> Assert . That ( entry . Equals ( ipAddress ) , Is . EqualTo ( expected ) ) ;
390
390
391
+ private static System . Collections . IEnumerable YieldTestCases_Equals_OfIPAddress_ShouldConsiderIPv4MappedIPv6Address ( )
392
+ {
393
+ var ipv4AddressEntry = new AddressTableEntry (
394
+ ipAddress : TestIPAddress ,
395
+ physicalAddress : null ,
396
+ isPermanent : true ,
397
+ state : AddressTableEntryState . None ,
398
+ interfaceId : null
399
+ ) ;
400
+ var ipv4MappedIPv6AddressEntry = new AddressTableEntry (
401
+ ipAddress : TestIPAddress . MapToIPv6 ( ) ,
402
+ physicalAddress : null ,
403
+ isPermanent : true ,
404
+ state : AddressTableEntryState . None ,
405
+ interfaceId : null
406
+ ) ;
407
+ IPAddress ? nullIPAddress = null ;
408
+
409
+ foreach ( var shouldConsiderIPv4MappedIPv6Address in new [ ] { true , false } ) {
410
+ yield return new object ? [ ] {
411
+ ipv4AddressEntry ,
412
+ nullIPAddress ,
413
+ shouldConsiderIPv4MappedIPv6Address ,
414
+ false
415
+ } ;
416
+ yield return new object ? [ ] {
417
+ ipv4AddressEntry ,
418
+ ipv4AddressEntry . IPAddress ,
419
+ shouldConsiderIPv4MappedIPv6Address ,
420
+ true
421
+ } ;
422
+ yield return new object ? [ ] {
423
+ ipv4AddressEntry ,
424
+ ipv4AddressEntry . IPAddress ! . MapToIPv6 ( ) , // compare with IPv4-mapped IPv6 address
425
+ shouldConsiderIPv4MappedIPv6Address ,
426
+ shouldConsiderIPv4MappedIPv6Address
427
+ } ;
428
+ }
429
+
430
+ foreach ( var shouldConsiderIPv4MappedIPv6Address in new [ ] { true , false } ) {
431
+ yield return new object ? [ ] {
432
+ ipv4MappedIPv6AddressEntry ,
433
+ nullIPAddress ,
434
+ shouldConsiderIPv4MappedIPv6Address ,
435
+ false
436
+ } ;
437
+ yield return new object ? [ ] {
438
+ ipv4MappedIPv6AddressEntry ,
439
+ ipv4MappedIPv6AddressEntry . IPAddress ,
440
+ shouldConsiderIPv4MappedIPv6Address ,
441
+ true
442
+ } ;
443
+ yield return new object ? [ ] {
444
+ ipv4MappedIPv6AddressEntry ,
445
+ ipv4MappedIPv6AddressEntry . IPAddress ! . MapToIPv4 ( ) , // compare with IPv4-mapped IPv6 address
446
+ shouldConsiderIPv4MappedIPv6Address ,
447
+ shouldConsiderIPv4MappedIPv6Address
448
+ } ;
449
+ }
450
+
451
+ var nullIPAddressEntry = default ( AddressTableEntry ) ;
452
+
453
+ foreach ( var shouldConsiderIPv4MappedIPv6Address in new [ ] { true , false } ) {
454
+ yield return new object ? [ ] {
455
+ nullIPAddressEntry ,
456
+ nullIPAddress ,
457
+ shouldConsiderIPv4MappedIPv6Address ,
458
+ true
459
+ } ;
460
+ yield return new object ? [ ] {
461
+ nullIPAddressEntry ,
462
+ TestIPAddress ,
463
+ shouldConsiderIPv4MappedIPv6Address ,
464
+ false
465
+ } ;
466
+ yield return new object ? [ ] {
467
+ nullIPAddressEntry ,
468
+ TestIPAddress . MapToIPv6 ( ) ,
469
+ shouldConsiderIPv4MappedIPv6Address ,
470
+ false
471
+ } ;
472
+ }
473
+ }
474
+
475
+ [ TestCaseSource ( nameof ( YieldTestCases_Equals_OfIPAddress_ShouldConsiderIPv4MappedIPv6Address ) ) ]
476
+ public void Equals_OfIPAddress_ShouldConsiderIPv4MappedIPv6Address ( AddressTableEntry entry , IPAddress ? ipAddress , bool shouldConsiderIPv4MappedIPv6Address , bool expected )
477
+ => Assert . That ( entry . Equals ( ipAddress , shouldConsiderIPv4MappedIPv6Address ) , Is . EqualTo ( expected ) ) ;
478
+
391
479
[ Test ]
392
480
public void Equals_PhysicalAddressNull ( )
393
481
{
0 commit comments