Skip to content

Commit cc23e6b

Browse files
committed
chore: migrate to Primary constructors and collection expressions
1 parent f1fde96 commit cc23e6b

File tree

75 files changed

+305
-520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+305
-520
lines changed

Algorithms.Tests/Crypto/Digests/AsconDigestTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void AsconHash_WhenGetByteLengthIsCalled_ReturnsCorrectValue()
159159
public void Update_ShouldProcessByte_WhenBufferIsFull()
160160
{
161161
// Arrange
162-
byte[] inputBytes = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; // 8 bytes to fill the buffer
162+
byte[] inputBytes = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77]; // 8 bytes to fill the buffer
163163

164164
// Act
165165
foreach (var input in inputBytes)
@@ -178,7 +178,7 @@ public void Update_ShouldProcessByte_WhenBufferIsFull()
178178
public void Update_ShouldNotProcess_WhenBufferIsNotFull()
179179
{
180180
// Arrange
181-
byte[] inputBytes = { 0x00, 0x11, 0x22, 0x33 }; // Only 4 bytes (buffer is not full)
181+
byte[] inputBytes = [0x00, 0x11, 0x22, 0x33]; // Only 4 bytes (buffer is not full)
182182

183183
// Act
184184
foreach (var input in inputBytes)
@@ -233,7 +233,7 @@ public void Update_ShouldHandleSingleByteCorrectly()
233233
public void Update_ShouldAccumulateStateWithMultipleUpdates()
234234
{
235235
// Arrange
236-
byte[] inputBytes = { 0x00, 0x11, 0x22 }; // Partial input
236+
byte[] inputBytes = [0x00, 0x11, 0x22]; // Partial input
237237

238238
// Act
239239
foreach (var input in inputBytes)
@@ -242,7 +242,7 @@ public void Update_ShouldAccumulateStateWithMultipleUpdates()
242242
}
243243

244244
// Add more data to fill the buffer.
245-
byte[] additionalBytes = { 0x33, 0x44, 0x55, 0x66, 0x77 };
245+
byte[] additionalBytes = [0x33, 0x44, 0x55, 0x66, 0x77];
246246
foreach (var input in additionalBytes)
247247
{
248248
asconHashA.Update(input);

Algorithms.Tests/Crypto/Paddings/Iso7816D4PaddingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Algorithms.Crypto.Paddings;
1+
using Algorithms.Crypto.Paddings;
22

33
namespace Algorithms.Tests.Crypto.Paddings;
44

@@ -75,7 +75,7 @@ public void RemovePadding_WhenCalledWithValidInput_shouldReturnCorrectData()
7575

7676
var result = padding.RemovePadding(inputData);
7777

78-
result.Should().Equal(new byte[] { 1, 2, 3, 4, 5 });
78+
result.Should().Equal([1, 2, 3, 4, 5]);
7979
}
8080

8181
[Test]

Algorithms.Tests/Crypto/Utils/ByteEncodingUtils.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class ByteEncodingUtilsTests
99
public void BigEndianToUint64_ByteArray_ShouldConvertCorrectly()
1010
{
1111
// Arrange
12-
byte[] input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
12+
byte[] input = [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF];
1313
var expected = 0x0123456789ABCDEFUL;
1414

1515
// Act
@@ -23,7 +23,7 @@ public void BigEndianToUint64_ByteArray_ShouldConvertCorrectly()
2323
public void BigEndianToUint64_ByteArray_WithOffset_ShouldConvertCorrectly()
2424
{
2525
// Arrange
26-
byte[] input = { 0x00, 0x00, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
26+
byte[] input = [0x00, 0x00, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF];
2727
var expected = 0x0123456789ABCDEFUL;
2828

2929
// Act
@@ -53,7 +53,7 @@ public void UInt64ToBigEndian_ShouldWriteCorrectly()
5353
// Arrange
5454
var value = 0x0123456789ABCDEFUL;
5555
Span<byte> output = stackalloc byte[8];
56-
byte[] expected = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
56+
byte[] expected = [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF];
5757

5858
// Act
5959
ByteEncodingUtils.UInt64ToBigEndian(value, output);
@@ -66,7 +66,7 @@ public void UInt64ToBigEndian_ShouldWriteCorrectly()
6666
public void BigEndianToUint64_InvalidOffset_ShouldThrowException()
6767
{
6868
// Arrange
69-
byte[] input = { 0x01, 0x23 };
69+
byte[] input = [0x01, 0x23];
7070

7171
// Act
7272
Action act = () => ByteEncodingUtils.BigEndianToUint64(input, 1);

Algorithms.Tests/Encoders/NysiisEncoderTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ namespace Algorithms.Tests.Encoders;
55
public class NysiisEncoderTests
66
{
77
private static readonly string[] Names =
8-
{
8+
[
99
"Jay", "John", "Jane", "Zayne", "Guerra", "Iga", "Cowan", "Louisa", "Arnie", "Olsen", "Corban", "Nava",
1010
"Cynthia Malone", "Amiee MacKee", "MacGyver", "Yasmin Edge",
11-
};
11+
];
1212

1313
private static readonly string[] Expected =
14-
{
14+
[
1515
"JY", "JAN", "JAN", "ZAYN", "GAR", "IG", "CAN", "LAS", "ARNY", "OLSAN", "CARBAN", "NAV", "CYNTANALAN",
1616
"ANANACY", "MCGYVAR", "YASNANADG",
17-
};
17+
];
1818

1919
private static IEnumerable<string[]> TestData => Names.Zip(Expected, (l, r) => new[] { l, r });
2020

Algorithms.Tests/Encoders/SoundexEncoderTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ namespace Algorithms.Tests.Encoders;
55
public static class SoundexEncoderTest
66
{
77
private static readonly string[] Names =
8-
{
8+
[
99
"Robert", "Rupert", "Rubin", "Ashcraft", "Ashcroft", "Tymczak", "Pfister", "Honeyman",
10-
};
10+
];
1111

12-
private static readonly string[] Expected = { "R163", "R163", "R150", "A261", "A261", "T522", "P236", "H555" };
12+
private static readonly string[] Expected = ["R163", "R163", "R150", "A261", "A261", "T522", "P236", "H555"];
1313

1414
private static IEnumerable<string[]> TestData => Names.Zip(Expected, (l, r) => new[] { l, r });
1515

Algorithms.Tests/Graph/BreadthFirstTreeTraversalTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public static class BreadthFirstTreeTraversalTests
99
public static void CorrectLevelOrderTraversal()
1010
{
1111
// Arrange
12-
int[] correctPath = { 7, 4, 13, 2, 5, 11, 15, 14, 16 };
13-
int[] insertionOrder = { 7, 13, 11, 15, 14, 4, 5, 16, 2 };
12+
int[] correctPath = [7, 4, 13, 2, 5, 11, 15, 14, 16];
13+
int[] insertionOrder = [7, 13, 11, 15, 14, 4, 5, 16, 2];
1414
BinarySearchTree<int> testTree = new BinarySearchTree<int>();
1515
foreach (int data in insertionOrder)
1616
{
@@ -60,7 +60,7 @@ public static void DeepestNodeInTree()
6060
{
6161
// Arrange
6262
BinarySearchTree<int> testTree = new BinarySearchTree<int>();
63-
int[] insertion = { 7, 13, 11, 15, 4, 5, 12, 2, 9 };
63+
int[] insertion = [7, 13, 11, 15, 4, 5, 12, 2, 9];
6464
foreach (int data in insertion)
6565
{
6666
testTree.Add(data);

Algorithms.Tests/LinearAlgebra/Eigenvalue/PowerIterationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Algorithms.Tests.LinearAlgebra.Eigenvalue;
55
public class PowerIterationTests
66
{
77
private static readonly object[] DominantVectorTestCases =
8-
{
8+
[
99
new object[]
1010
{
1111
3.0,
@@ -18,7 +18,7 @@ public class PowerIterationTests
1818
new[] { 0.91287093, 0.40824829 },
1919
new[,] { { 2.0, 5.0 }, { 1.0, 2.0 } },
2020
},
21-
};
21+
];
2222

2323
private readonly double epsilon = Math.Pow(10, -5);
2424

Algorithms.Tests/Numeric/NewtonSquareRootTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
namespace Algorithms.Tests.Numeric;
1+
namespace Algorithms.Tests.Numeric;
22

33
public class NewtonSquareRootTests
44
{
55
private static readonly object[] CalculateSquareRootInput =
6-
{
6+
[
77
new object[] {BigInteger.One, BigInteger.One},
88
new object[] {new BigInteger(221295376), new BigInteger(14876)},
99
new object[] {new BigInteger(2530995481), new BigInteger(50309)},
@@ -13,7 +13,7 @@ public class NewtonSquareRootTests
1313
new object[] {new BigInteger(5551442064), new BigInteger(74508)},
1414
new object[] {new BigInteger(6980435401), new BigInteger(83549)},
1515
new object[] {new BigInteger(8036226025), new BigInteger(89645)},
16-
};
16+
];
1717

1818
[TestCaseSource(nameof(CalculateSquareRootInput))]
1919
public void CalculateSquareRootTest(BigInteger number, BigInteger result)

Algorithms.Tests/Other/JulianEasterTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public static void CalculateTest(int year, DateTime expected)
1616
}
1717

1818
private static readonly object[] CalculateCases =
19-
{
19+
[
2020
new object[] { 1800, new DateTime(1800, 04, 08, 00, 00, 00, DateTimeKind.Utc) },
2121
new object[] { 1950, new DateTime(1950, 03, 27, 00, 00, 00, DateTimeKind.Utc) },
2222
new object[] { 1991, new DateTime(1991, 03, 25, 00, 00, 00, DateTimeKind.Utc) },
2323
new object[] { 2000, new DateTime(2000, 04, 17, 00, 00, 00, DateTimeKind.Utc) },
2424
new object[] { 2199, new DateTime(2199, 04, 07, 00, 00, 00, DateTimeKind.Utc) }
25-
};
25+
];
2626

2727
}

Algorithms.Tests/Other/SieveOfEratosthenesTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Algorithms.Tests.Other;
55
public static class SieveOfEratosthenesTests
66
{
77
private static readonly long[] First10000PrimeNumbers =
8-
{
8+
[
99
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,
1010
107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,
1111
227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347,
@@ -662,7 +662,7 @@ public static class SieveOfEratosthenesTests
662662
104383, 104393, 104399, 104417, 104459, 104471, 104473, 104479, 104491, 104513, 104527, 104537, 104543,
663663
104549, 104551, 104561, 104579, 104593, 104597, 104623, 104639, 104651, 104659, 104677, 104681, 104683,
664664
104693, 104701, 104707, 104711, 104717, 104723, 104729,
665-
};
665+
];
666666

667667
[Test]
668668
public static void First10_000PrimesCorrect() =>

0 commit comments

Comments
 (0)