Skip to content

Commit 5c257fc

Browse files
secret-handshake: add generator
1 parent 3078dc1 commit 5c257fc

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Xunit;
2+
3+
public class {{testClass}}
4+
{
5+
{{for test in tests}}
6+
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7+
public void {{test.testMethod}}()
8+
{
9+
string[] expected = {{test.expected}};
10+
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.number}}));
11+
}
12+
{{end}}
13+
}

exercises/practice/secret-handshake/SecretHandshakeTests.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,77 @@ public class SecretHandshakeTests
55
[Fact]
66
public void Wink_for_1()
77
{
8-
Assert.Equal(new[] { "wink" }, SecretHandshake.Commands(1));
8+
string[] expected = ["wink"];
9+
Assert.Equal(expected, SecretHandshake.Commands(1));
910
}
1011

1112
[Fact(Skip = "Remove this Skip property to run this test")]
1213
public void Double_blink_for_10()
1314
{
14-
Assert.Equal(new[] { "double blink" }, SecretHandshake.Commands(2));
15+
string[] expected = ["double blink"];
16+
Assert.Equal(expected, SecretHandshake.Commands(2));
1517
}
1618

1719
[Fact(Skip = "Remove this Skip property to run this test")]
1820
public void Close_your_eyes_for_100()
1921
{
20-
Assert.Equal(new[] { "close your eyes" }, SecretHandshake.Commands(4));
22+
string[] expected = ["close your eyes"];
23+
Assert.Equal(expected, SecretHandshake.Commands(4));
2124
}
2225

2326
[Fact(Skip = "Remove this Skip property to run this test")]
2427
public void Jump_for_1000()
2528
{
26-
Assert.Equal(new[] { "jump" }, SecretHandshake.Commands(8));
29+
string[] expected = ["jump"];
30+
Assert.Equal(expected, SecretHandshake.Commands(8));
2731
}
2832

2933
[Fact(Skip = "Remove this Skip property to run this test")]
3034
public void Combine_two_actions()
3135
{
32-
Assert.Equal(new[] { "wink", "double blink" }, SecretHandshake.Commands(3));
36+
string[] expected = ["wink", "double blink"];
37+
Assert.Equal(expected, SecretHandshake.Commands(3));
3338
}
3439

3540
[Fact(Skip = "Remove this Skip property to run this test")]
3641
public void Reverse_two_actions()
3742
{
38-
Assert.Equal(new[] { "double blink", "wink" }, SecretHandshake.Commands(19));
43+
string[] expected = ["double blink", "wink"];
44+
Assert.Equal(expected, SecretHandshake.Commands(19));
3945
}
4046

4147
[Fact(Skip = "Remove this Skip property to run this test")]
4248
public void Reversing_one_action_gives_the_same_action()
4349
{
44-
Assert.Equal(new[] { "jump" }, SecretHandshake.Commands(24));
50+
string[] expected = ["jump"];
51+
Assert.Equal(expected, SecretHandshake.Commands(24));
4552
}
4653

4754
[Fact(Skip = "Remove this Skip property to run this test")]
4855
public void Reversing_no_actions_still_gives_no_actions()
4956
{
50-
Assert.Empty(SecretHandshake.Commands(16));
57+
string[] expected = [];
58+
Assert.Equal(expected, SecretHandshake.Commands(16));
5159
}
5260

5361
[Fact(Skip = "Remove this Skip property to run this test")]
5462
public void All_possible_actions()
5563
{
56-
Assert.Equal(new[] { "wink", "double blink", "close your eyes", "jump" }, SecretHandshake.Commands(15));
64+
string[] expected = ["wink", "double blink", "close your eyes", "jump"];
65+
Assert.Equal(expected, SecretHandshake.Commands(15));
5766
}
5867

5968
[Fact(Skip = "Remove this Skip property to run this test")]
6069
public void Reverse_all_possible_actions()
6170
{
62-
Assert.Equal(new[] { "jump", "close your eyes", "double blink", "wink" }, SecretHandshake.Commands(31));
71+
string[] expected = ["jump", "close your eyes", "double blink", "wink"];
72+
Assert.Equal(expected, SecretHandshake.Commands(31));
6373
}
6474

6575
[Fact(Skip = "Remove this Skip property to run this test")]
6676
public void Do_nothing_for_zero()
6777
{
68-
Assert.Empty(SecretHandshake.Commands(0));
78+
string[] expected = [];
79+
Assert.Equal(expected, SecretHandshake.Commands(0));
6980
}
7081
}

0 commit comments

Comments
 (0)