File tree 3 files changed +38
-28
lines changed
algorithm_exercises_csharp_test
Resources/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps
src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps
3 files changed +38
-28
lines changed Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "title" : " Example 1" ,
4
+ "s1" : " and" ,
5
+ "s2" : " art" ,
6
+ "expected" : " Yes"
7
+ },
8
+ {
9
+ "title" : " Example 2" ,
10
+ "s1" : " be" ,
11
+ "s2" : " cat" ,
12
+ "expected" : " No"
13
+ },
14
+ {
15
+ "title" : " Sample Test Case 0" ,
16
+ "s1" : " hello" ,
17
+ "s2" : " world" ,
18
+ "expected" : " Yes"
19
+ }
20
+ ]
Original file line number Diff line number Diff line change 61
61
<ItemGroup >
62
62
<EmbeddedResource Include =" Resources/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.testcases.json" />
63
63
<EmbeddedResource Include =" Resources/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/ctci_ransom_note.testcases.json" />
64
+ <EmbeddedResource Include =" Resources/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.testcases.json" />
64
65
</ItemGroup >
65
66
</Project >
Original file line number Diff line number Diff line change @@ -5,42 +5,31 @@ public class TwoStringsTest
5
5
{
6
6
public class TwoStringsTestCase
7
7
{
8
- public string title = "" ;
9
- public string s1 = "" ;
10
- public string s2 = "" ;
11
- public string expected = "Yes" ;
8
+ public string title { get ; set ; } = default ! ;
9
+
10
+ public string s1 { get ; set ; } = default ! ;
11
+
12
+ public string s2 { get ; set ; } = default ! ;
13
+
14
+ public string expected { get ; set ; } = default ! ;
12
15
}
13
16
14
- private static readonly TwoStringsTestCase [ ] tests = [
15
- new ( )
16
- {
17
- title = "Example 1" ,
18
- s1 = "and" ,
19
- s2 = "art" ,
20
- expected = "Yes"
21
- } ,
22
- new ( )
23
- {
24
- title = "Example 2" ,
25
- s1 = "be" ,
26
- s2 = "cat" ,
27
- expected = "No"
28
- } ,
29
- new ( )
30
- {
31
- title = "Sample Test Case 0" ,
32
- s1 = "hello" ,
33
- s2 = "world" ,
34
- expected = "Yes"
35
- } ,
36
- ] ;
17
+ private List < TwoStringsTestCase > testCases { get ; set ; } = default ! ;
18
+
19
+ [ TestInitialize ]
20
+ public void testInitialize ( )
21
+ {
22
+ testCases = JsonLoader . resourceLoad < List < TwoStringsTestCase > > (
23
+ "hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/two_strings.testcases.json"
24
+ ) ?? [ ] ;
25
+ }
37
26
38
27
[ TestMethod ]
39
28
public void testTwoStrings ( )
40
29
{
41
30
string result ;
42
31
43
- foreach ( TwoStringsTestCase test in tests )
32
+ foreach ( TwoStringsTestCase test in testCases )
44
33
{
45
34
result = TwoStrings . twoStrings ( test . s1 , test . s2 ) ;
46
35
Assert . AreEqual ( test . expected , result ) ;
You can’t perform that action at this time.
0 commit comments