Skip to content

Commit 1b72837

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] test setter
1 parent b9da31f commit 1b72837

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/algorithm_exercises_csharp_test/hackerrank/interview_preparation_kit/arrays/ArraysLeftRotation.Test.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ public class ArraysLeftRotationTest
77
{
88
public class ArraysLeftRotationsTestCase
99
{
10-
public List<int> input { get; } = default!;
10+
public List<int> input { get; set; } = default!;
1111
public int d { get; set; }
12-
public List<int> expected { get; } = default!;
12+
public List<int> expected { get; set; } = default!;
1313
}
1414

1515
private List<ArraysLeftRotationsTestCase> testCases = default!;

src/algorithm_exercises_csharp_test/hackerrank/interview_preparation_kit/arrays/CrushBruteForce.Test.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class CrushBruteForceTest
88
public class CrushBruteForceTestCase
99
{
1010
public string title { get; set; } = default!;
11-
public List<List<int>> queries { get; } = default!;
11+
public List<List<int>> queries { get; set; } = default!;
1212
public int n { get; set; } = default!;
1313
public long expected { get; set; } = default!;
1414
}

src/algorithm_exercises_csharp_test/hackerrank/projecteuler/Euler001.Test.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ public class Euler001Test
66
{
77
public class Euler001TestCase
88
{
9-
public int a; public int b; public int n; public int answer;
9+
public int A { get; set; }
10+
public int B { get; set; }
11+
public int N { get; set; }
12+
public int Answer { get; set; }
1013
}
1114

12-
// dotnet_style_readonly_field = true
1315
private static readonly Euler001TestCase[] tests = [
14-
new() { a = 3, b = 5, n = 10, answer = 23 },
15-
new() { a = 3, b = 5, n = 100, answer = 2318 },
16-
new() { a = 3, b = 5, n = 1000, answer = 233168 },
17-
16+
new() { A = 3, B = 5, N = 10, Answer = 23 },
17+
new() { A = 3, B = 5, N = 100, Answer = 2318 },
18+
new() { A = 3, B = 5, N = 1000, Answer = 233168 }
1819
];
1920

2021
[TestMethod]
@@ -24,8 +25,8 @@ public void euler001Test()
2425

2526
foreach (Euler001TestCase test in tests)
2627
{
27-
result = Euler001.euler001(test.a, test.b, test.n);
28-
Assert.AreEqual(test.answer, result);
28+
result = Euler001.euler001(test.A, test.B, test.N);
29+
Assert.AreEqual(test.Answer, result);
2930
}
3031
}
3132
}

src/algorithm_exercises_csharp_test/hackerrank/projecteuler/Euler002.Test.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ public class Euler002Test
66
{
77
public class Euler002TestCase
88
{
9-
public int n; public int answer;
9+
public int N { get; set; }
10+
public int Answer { get; set; }
1011
}
1112

12-
// dotnet_style_readonly_field = true
1313
private static readonly Euler002TestCase[] tests = [
14-
new() { n = 10, answer = 10 },
15-
new() { n = 100, answer = 44 }
14+
new() { N = 10, Answer = 10 },
15+
new() { N = 100, Answer = 44 }
1616
];
1717

1818
[TestMethod]
1919
public void euler002Test()
2020
{
2121
int result;
22-
2322
foreach (Euler002TestCase test in tests)
2423
{
25-
result = Euler002.euler002(test.n);
26-
Assert.AreEqual(test.answer, result);
24+
result = Euler002.euler002(test.N);
25+
Assert.AreEqual(test.Answer, result);
2726
}
2827
}
2928
}
3029

30+

src/algorithm_exercises_csharp_test/hackerrank/projecteuler/Euler003.Test.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@ public class Euler003Test
66
{
77
public class Euler003TestCase
88
{
9-
public int n; public int? answer;
9+
public int N { get; set; }
10+
public int? Answer { get; set; }
1011
}
1112

12-
// dotnet_style_readonly_field = true
1313
private static readonly Euler003TestCase[] tests = [
14-
new() { n = 1, answer = null },
15-
new() { n = 10, answer = 5 },
16-
new() { n = 17, answer = 17 }
14+
new() { N = 1, Answer = null },
15+
new() { N = 10, Answer = 5 },
16+
new() { N = 17, Answer = 17 }
1717
];
1818

1919
[TestMethod]
2020
public void euler003Test()
2121
{
2222
int? result;
23-
2423
foreach (Euler003TestCase test in tests)
2524
{
26-
result = Euler003.euler003(test.n);
27-
Assert.AreEqual(test.answer, result);
25+
result = Euler003.euler003(test.N);
26+
Assert.AreEqual(test.Answer, result);
2827
}
2928
}
3029
}

0 commit comments

Comments
 (0)