Skip to content

Commit 3cfdf90

Browse files
committed
Fix: quality
1 parent 720ab04 commit 3cfdf90

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/System.Net.IPNetwork/UniqueLocalAddress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static IPNetwork2 GenerateUlaPrefix(string seed)
8181
{
8282
if (string.IsNullOrEmpty(seed))
8383
{
84-
throw new ArgumentNullException("Seed cannot be null or empty", nameof(seed));
84+
throw new ArgumentNullException(nameof(seed), "Seed cannot be null or empty");
8585
}
8686

8787
byte[] globalId = GenerateGlobalIdFromSeed(seed);

src/TestProject/IPAddressExtensionTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ e XOR'd with the byte count so the two sequences will be different. */
9898
foreach (int i in Enumerable.Range(1, 1000))
9999
{
100100
/* Hash the current interation to get a new block of deterministic bytes. */
101-
using (var hash = SHA256.Create())
102-
{
103-
hashInput = hash.ComputeHash(hashInput);
104-
}
101+
hashInput = SHA256.HashData(hashInput);
105102

106103
/* Convert the first n bytes for an address. 4 will have an IPv4. 16 will make an IPv6. */
107104
yield return new IPAddress(hashInput.Take(byteCount).ToArray()).ToString();

src/TestProject/UniqueLocalAddressTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public void TestUlaGeneration_ProducesUniqueResults()
362362
}
363363

364364
// Assert - Should produce mostly unique results
365-
Assert.IsTrue(generatedUlas.Count > iterations * 0.9,
365+
Assert.IsGreaterThan(iterations * 0.9, generatedUlas.Count,
366366
"ULA generation should produce highly unique results");
367367
}
368368

@@ -421,7 +421,7 @@ public void GenerateUlaPrefix_NoSeed_Tends_To_Vary()
421421
seen.Add(UniqueLocalAddress.GenerateUlaPrefix().ToString());
422422
}
423423

424-
Assert.IsTrue(seen.Count >= 2, "Multiple calls should usually produce at least two distinct prefixes.");
424+
Assert.IsGreaterThanOrEqualTo(2, seen.Count, "Multiple calls should usually produce at least two distinct prefixes.");
425425
}
426426

427427
/// <summary>

0 commit comments

Comments
 (0)