Skip to content

Commit 73c89d8

Browse files
authored
Make quality of life improvements (#275)
1 parent d134e03 commit 73c89d8

Some content is hidden

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

42 files changed

+426
-430
lines changed

Algorithms.Tests/Encoders/FeistelCipherTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public static void DecodedStringIsTheSame([Random(100)] uint key)
1414
var encoder = new FeistelCipher();
1515
var random = new Randomizer();
1616

17-
int len_of_string = random.Next(1000);
17+
int lenOfString = random.Next(1000);
1818

19-
string message = random.GetString(len_of_string);
19+
string message = random.GetString(lenOfString);
2020

2121
// Act
2222
var encoded = encoder.Encode(message, key);
@@ -33,13 +33,13 @@ public static void DecodedStringIsTheSame([Random(100)] uint key)
3333
[TestCase("0000111122223333444455556666777", (uint)0x12345678)]
3434
// The plain text will be padded to fill the size of block (16 bytes), so the encoded message should be aligned with the rule
3535
// (text.Length % 16 == 0)
36-
public static void TestEncodedMessageSize(string TestCase, uint Key)
36+
public static void TestEncodedMessageSize(string testCase, uint key)
3737
{
3838
// Arrange
3939
var encoder = new FeistelCipher();
4040

4141
// Assert
42-
Assert.Throws<ArgumentException>(() => encoder.Decode(TestCase, Key));
42+
Assert.Throws<ArgumentException>(() => encoder.Decode(testCase, key));
4343
}
4444
}
4545
}

Algorithms.Tests/Encoders/NysiisEncoderTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ namespace Algorithms.Tests.Encoders
77
{
88
public class NysiisEncoderTests
99
{
10-
private static readonly string[] _names =
10+
private static readonly string[] Names =
1111
{
1212
"Jay", "John", "Jane", "Zayne", "Guerra", "Iga", "Cowan", "Louisa", "Arnie", "Olsen", "Corban", "Nava",
1313
"Cynthia Malone", "Amiee MacKee", "MacGyver", "Yasmin Edge",
1414
};
1515

16-
private static readonly string[] _expected =
16+
private static readonly string[] Expected =
1717
{
1818
"JY", "JAN", "JAN", "ZAYN", "GAR", "IG", "CAN", "LAS", "ARNY", "OLSAN", "CARBAN", "NAV", "CYNTANALAN",
1919
"ANANACY", "MCGYVAR", "YASNANADG",
2020
};
2121

22-
private static IEnumerable<string[]> TestData => _names.Zip(_expected, (l, r) => new[] { l, r });
22+
private static IEnumerable<string[]> TestData => Names.Zip(Expected, (l, r) => new[] { l, r });
2323

2424
[TestCaseSource(nameof(TestData))]
2525
public void AttemptNysiis(string source, string expected)

Algorithms.Tests/Encoders/SoundexEncoderTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ namespace Algorithms.Tests.Encoders
77
{
88
public static class SoundexEncoderTest
99
{
10-
private static readonly string[] _names =
10+
private static readonly string[] Names =
1111
{
1212
"Robert", "Rupert", "Rubin", "Ashcraft", "Ashcroft", "Tymczak", "Pfister", "Honeyman",
1313
};
1414

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

17-
private static IEnumerable<string[]> TestData => _names.Zip(_expected, (l, r) => new[] { l, r });
17+
private static IEnumerable<string[]> TestData => Names.Zip(Expected, (l, r) => new[] { l, r });
1818

1919
[TestCaseSource(nameof(TestData))]
2020
public static void AttemptSoundex(string source, string encoded)

Algorithms.Tests/Graph/BreadthFirstSearchTests.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void VisitAll_ShouldCountNumberOfVisitedVertix_ResultShouldBeTheSameAsNum
3434
long countOfVisitedVertices = 0;
3535

3636
//Act
37-
dfsSearcher.VisitAll(graph, vertex1, (Vertex<int> vertex) => countOfVisitedVertices++);
37+
dfsSearcher.VisitAll(graph, vertex1, _ => countOfVisitedVertices++);
3838

3939
//Assert
4040
Assert.AreEqual(countOfVisitedVertices, graph.Count);
@@ -73,9 +73,9 @@ public void VisitAll_ShouldCountNumberOfVisitedVerices_TwoSeparatedGraphInOne()
7373
long countOfVisitedVerticesPerSecondGraph = 0;
7474

7575
//Act
76-
dfsSearcher.VisitAll(graph, vertex1, (Vertex<int> vertex) => countOfVisitedVerticesPerFirstGraph++);
76+
dfsSearcher.VisitAll(graph, vertex1, _ => countOfVisitedVerticesPerFirstGraph++);
7777

78-
dfsSearcher.VisitAll(graph, vertex4, (Vertex<int> vertex) => countOfVisitedVerticesPerSecondGraph++);
78+
dfsSearcher.VisitAll(graph, vertex4, _ => countOfVisitedVerticesPerSecondGraph++);
7979

8080
//Assert
8181
Assert.AreEqual(countOfVisitedVerticesPerFirstGraph, 3);
@@ -117,13 +117,13 @@ public void VisitAll_ReturnTheSuqenceOfVertices_ShouldBeTheSameAsExpected()
117117
vertex2,
118118
vertex5,
119119
vertex3,
120-
vertex4
120+
vertex4,
121121
};
122122

123123
var sequenceOfVisitedVertices = new List<Vertex<int>>();
124124

125125
//Act
126-
dfsSearcher.VisitAll(graph, vertex1, (Vertex<int> vertex) => sequenceOfVisitedVertices.Add(vertex));
126+
dfsSearcher.VisitAll(graph, vertex1, vertex => sequenceOfVisitedVertices.Add(vertex));
127127

128128
//Assert
129129
CollectionAssert.AreEqual(expectedSequenceOfVisitedVertices, sequenceOfVisitedVertices);

Algorithms.Tests/Graph/DepthFirstSearchTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ public void VisitAll_ShouldCountNumberOfVisitedVertix_ResultShouldBeTheSameAsNum
3434
long countOfVisitedVertices = 0;
3535

3636
//Act
37-
dfsSearcher.VisitAll(graph, vertex1, (Vertex<int> vertex) => countOfVisitedVertices++);
37+
dfsSearcher.VisitAll(graph, vertex1, _ => countOfVisitedVertices++);
3838

3939
//Assert
4040
Assert.AreEqual(countOfVisitedVertices, graph.Count);
4141
}
4242

4343
[Test]
44-
public void VisitAll_ShouldCountNumberOfVisitedVerices_TwoSeparatedGraphInOne()
44+
public void VisitAll_ShouldCountNumberOfVisitedVertices_TwoSeparatedGraphInOne()
4545
{
4646
//Arrange
4747
var graph = new DirectedWeightedGraph<int>(10);
@@ -73,9 +73,9 @@ public void VisitAll_ShouldCountNumberOfVisitedVerices_TwoSeparatedGraphInOne()
7373
long countOfVisitedVerticesPerSecondGraph = 0;
7474

7575
//Act
76-
dfsSearcher.VisitAll(graph, vertex1, (Vertex<int> vertex) => countOfVisitedVerticesPerFirstGraph++);
76+
dfsSearcher.VisitAll(graph, vertex1, _ => countOfVisitedVerticesPerFirstGraph++);
7777

78-
dfsSearcher.VisitAll(graph, vertex4, (Vertex<int> vertex) => countOfVisitedVerticesPerSecondGraph++);
78+
dfsSearcher.VisitAll(graph, vertex4, _ => countOfVisitedVerticesPerSecondGraph++);
7979

8080
//Assert
8181
Assert.AreEqual(countOfVisitedVerticesPerFirstGraph, 3);
@@ -115,13 +115,13 @@ public void VisitAll_ReturnTheSuqenceOfVertices_ShouldBeTheSameAsExpected()
115115
vertex2,
116116
vertex3,
117117
vertex5,
118-
vertex4
118+
vertex4,
119119
};
120120

121121
var sequenceOfVisitedVertices = new List<Vertex<int>>();
122122

123123
//Act
124-
dfsSearcher.VisitAll(graph, vertex1, (Vertex<int> vertex) => sequenceOfVisitedVertices.Add(vertex));
124+
dfsSearcher.VisitAll(graph, vertex1, vertex => sequenceOfVisitedVertices.Add(vertex));
125125

126126
//Assert
127127
CollectionAssert.AreEqual(expectedSequenceOfVisitedVertices, sequenceOfVisitedVertices);

Algorithms.Tests/Graph/FloydWarshallTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void CorrectMatrixTest()
4646
{ 3, 0, -4, 1, -1 },
4747
{ 7, 4, 0, 5, 3 },
4848
{ 2, -1, -5, 0, -2 },
49-
{ 8, 5, 1, 6, 0 }
49+
{ 8, 5, 1, 6, 0 },
5050
};
5151

5252
var floydWarshaller = new FloydWarshall<int>();

0 commit comments

Comments
 (0)