Skip to content

Commit 8c57d8e

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] Change {List-type property} to be read-only by removing the property setter (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2227)
1 parent 9ed5a56 commit 8c57d8e

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@ namespace algorithm_exercises_csharp_test.hackerrank.interview_preparation_kit.a
55
[TestClass]
66
public class NewYearChaosTest
77
{
8-
public class NewYearChaosTestCase
8+
public class NewYearChaosTestCase(string title, int[] input, string expected)
99
{
10-
public string title { get; set; } = default!;
11-
public List<int> input { get; set; } = default!;
12-
public string expected { get; set; } = default!;
10+
private readonly string title = title;
11+
private readonly List<int> input = [.. input];
12+
private readonly string expected = expected;
13+
14+
public string Title
15+
{
16+
get { return title; }
17+
}
18+
19+
public List<int> Input
20+
{
21+
get { return input; }
22+
}
23+
24+
public string Expected
25+
{
26+
get { return expected; }
27+
}
1328
}
1429

1530
private List<NewYearChaosTestCase> testCases { get; set; } = default!;
@@ -29,10 +44,10 @@ public void testMinimumBribesText()
2944

3045
foreach (NewYearChaosTestCase test in testCases)
3146
{
32-
result = NewYearChaos.minimumBribesText(test.input);
33-
NewYearChaos.minimumBribes(test.input);
47+
result = NewYearChaos.minimumBribesText(test.Input);
48+
NewYearChaos.minimumBribes(test.Input);
3449

35-
Assert.AreEqual(test.expected, result);
50+
Assert.AreEqual(test.Expected, result);
3651
}
3752
}
3853
}

0 commit comments

Comments
 (0)