Skip to content

Commit 958fe34

Browse files
yacht: add generator
1 parent 1c92fa8 commit 958fe34

File tree

3 files changed

+43
-41
lines changed

3 files changed

+43
-41
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using Xunit;
3+
4+
public class YachtTests
5+
{
6+
{{for testCase in testCases}}
7+
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
8+
public void {{testCase.testMethodName}}()
9+
{
10+
Assert.Equal({{testCase.expected}}, YachtGame.Score({{testCase.input.dice}}, {{testCase.input.category | enum "YachtCategory"}}));
11+
}
12+
{{end}}
13+
}
Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,179 @@
1+
using System;
12
using Xunit;
23

34
public class YachtTests
45
{
56
[Fact]
67
public void Yacht()
78
{
8-
Assert.Equal(50, YachtGame.Score(new[] { 5, 5, 5, 5, 5 }, YachtCategory.Yacht));
9+
Assert.Equal(50, YachtGame.Score([5, 5, 5, 5, 5], YachtCategory.Yacht));
910
}
1011

1112
[Fact(Skip = "Remove this Skip property to run this test")]
1213
public void Not_yacht()
1314
{
14-
Assert.Equal(0, YachtGame.Score(new[] { 1, 3, 3, 2, 5 }, YachtCategory.Yacht));
15+
Assert.Equal(0, YachtGame.Score([1, 3, 3, 2, 5], YachtCategory.Yacht));
1516
}
1617

1718
[Fact(Skip = "Remove this Skip property to run this test")]
1819
public void Ones()
1920
{
20-
Assert.Equal(3, YachtGame.Score(new[] { 1, 1, 1, 3, 5 }, YachtCategory.Ones));
21+
Assert.Equal(3, YachtGame.Score([1, 1, 1, 3, 5], YachtCategory.Ones));
2122
}
2223

2324
[Fact(Skip = "Remove this Skip property to run this test")]
2425
public void Ones_out_of_order()
2526
{
26-
Assert.Equal(3, YachtGame.Score(new[] { 3, 1, 1, 5, 1 }, YachtCategory.Ones));
27+
Assert.Equal(3, YachtGame.Score([3, 1, 1, 5, 1], YachtCategory.Ones));
2728
}
2829

2930
[Fact(Skip = "Remove this Skip property to run this test")]
3031
public void No_ones()
3132
{
32-
Assert.Equal(0, YachtGame.Score(new[] { 4, 3, 6, 5, 5 }, YachtCategory.Ones));
33+
Assert.Equal(0, YachtGame.Score([4, 3, 6, 5, 5], YachtCategory.Ones));
3334
}
3435

3536
[Fact(Skip = "Remove this Skip property to run this test")]
3637
public void Twos()
3738
{
38-
Assert.Equal(2, YachtGame.Score(new[] { 2, 3, 4, 5, 6 }, YachtCategory.Twos));
39+
Assert.Equal(2, YachtGame.Score([2, 3, 4, 5, 6], YachtCategory.Twos));
3940
}
4041

4142
[Fact(Skip = "Remove this Skip property to run this test")]
4243
public void Fours()
4344
{
44-
Assert.Equal(8, YachtGame.Score(new[] { 1, 4, 1, 4, 1 }, YachtCategory.Fours));
45+
Assert.Equal(8, YachtGame.Score([1, 4, 1, 4, 1], YachtCategory.Fours));
4546
}
4647

4748
[Fact(Skip = "Remove this Skip property to run this test")]
4849
public void Yacht_counted_as_threes()
4950
{
50-
Assert.Equal(15, YachtGame.Score(new[] { 3, 3, 3, 3, 3 }, YachtCategory.Threes));
51+
Assert.Equal(15, YachtGame.Score([3, 3, 3, 3, 3], YachtCategory.Threes));
5152
}
5253

5354
[Fact(Skip = "Remove this Skip property to run this test")]
5455
public void Yacht_of_3s_counted_as_fives()
5556
{
56-
Assert.Equal(0, YachtGame.Score(new[] { 3, 3, 3, 3, 3 }, YachtCategory.Fives));
57+
Assert.Equal(0, YachtGame.Score([3, 3, 3, 3, 3], YachtCategory.Fives));
5758
}
5859

5960
[Fact(Skip = "Remove this Skip property to run this test")]
6061
public void Fives()
6162
{
62-
Assert.Equal(10, YachtGame.Score(new[] { 1, 5, 3, 5, 3 }, YachtCategory.Fives));
63+
Assert.Equal(10, YachtGame.Score([1, 5, 3, 5, 3], YachtCategory.Fives));
6364
}
6465

6566
[Fact(Skip = "Remove this Skip property to run this test")]
6667
public void Sixes()
6768
{
68-
Assert.Equal(6, YachtGame.Score(new[] { 2, 3, 4, 5, 6 }, YachtCategory.Sixes));
69+
Assert.Equal(6, YachtGame.Score([2, 3, 4, 5, 6], YachtCategory.Sixes));
6970
}
7071

7172
[Fact(Skip = "Remove this Skip property to run this test")]
7273
public void Full_house_two_small_three_big()
7374
{
74-
Assert.Equal(16, YachtGame.Score(new[] { 2, 2, 4, 4, 4 }, YachtCategory.FullHouse));
75+
Assert.Equal(16, YachtGame.Score([2, 2, 4, 4, 4], YachtCategory.FullHouse));
7576
}
7677

7778
[Fact(Skip = "Remove this Skip property to run this test")]
7879
public void Full_house_three_small_two_big()
7980
{
80-
Assert.Equal(19, YachtGame.Score(new[] { 5, 3, 3, 5, 3 }, YachtCategory.FullHouse));
81+
Assert.Equal(19, YachtGame.Score([5, 3, 3, 5, 3], YachtCategory.FullHouse));
8182
}
8283

8384
[Fact(Skip = "Remove this Skip property to run this test")]
8485
public void Two_pair_is_not_a_full_house()
8586
{
86-
Assert.Equal(0, YachtGame.Score(new[] { 2, 2, 4, 4, 5 }, YachtCategory.FullHouse));
87+
Assert.Equal(0, YachtGame.Score([2, 2, 4, 4, 5], YachtCategory.FullHouse));
8788
}
8889

8990
[Fact(Skip = "Remove this Skip property to run this test")]
9091
public void Four_of_a_kind_is_not_a_full_house()
9192
{
92-
Assert.Equal(0, YachtGame.Score(new[] { 1, 4, 4, 4, 4 }, YachtCategory.FullHouse));
93+
Assert.Equal(0, YachtGame.Score([1, 4, 4, 4, 4], YachtCategory.FullHouse));
9394
}
9495

9596
[Fact(Skip = "Remove this Skip property to run this test")]
9697
public void Yacht_is_not_a_full_house()
9798
{
98-
Assert.Equal(0, YachtGame.Score(new[] { 2, 2, 2, 2, 2 }, YachtCategory.FullHouse));
99+
Assert.Equal(0, YachtGame.Score([2, 2, 2, 2, 2], YachtCategory.FullHouse));
99100
}
100101

101102
[Fact(Skip = "Remove this Skip property to run this test")]
102103
public void Four_of_a_kind()
103104
{
104-
Assert.Equal(24, YachtGame.Score(new[] { 6, 6, 4, 6, 6 }, YachtCategory.FourOfAKind));
105+
Assert.Equal(24, YachtGame.Score([6, 6, 4, 6, 6], YachtCategory.FourOfAKind));
105106
}
106107

107108
[Fact(Skip = "Remove this Skip property to run this test")]
108109
public void Yacht_can_be_scored_as_four_of_a_kind()
109110
{
110-
Assert.Equal(12, YachtGame.Score(new[] { 3, 3, 3, 3, 3 }, YachtCategory.FourOfAKind));
111+
Assert.Equal(12, YachtGame.Score([3, 3, 3, 3, 3], YachtCategory.FourOfAKind));
111112
}
112113

113114
[Fact(Skip = "Remove this Skip property to run this test")]
114115
public void Full_house_is_not_four_of_a_kind()
115116
{
116-
Assert.Equal(0, YachtGame.Score(new[] { 3, 3, 3, 5, 5 }, YachtCategory.FourOfAKind));
117+
Assert.Equal(0, YachtGame.Score([3, 3, 3, 5, 5], YachtCategory.FourOfAKind));
117118
}
118119

119120
[Fact(Skip = "Remove this Skip property to run this test")]
120121
public void Little_straight()
121122
{
122-
Assert.Equal(30, YachtGame.Score(new[] { 3, 5, 4, 1, 2 }, YachtCategory.LittleStraight));
123+
Assert.Equal(30, YachtGame.Score([3, 5, 4, 1, 2], YachtCategory.LittleStraight));
123124
}
124125

125126
[Fact(Skip = "Remove this Skip property to run this test")]
126127
public void Little_straight_as_big_straight()
127128
{
128-
Assert.Equal(0, YachtGame.Score(new[] { 1, 2, 3, 4, 5 }, YachtCategory.BigStraight));
129+
Assert.Equal(0, YachtGame.Score([1, 2, 3, 4, 5], YachtCategory.BigStraight));
129130
}
130131

131132
[Fact(Skip = "Remove this Skip property to run this test")]
132133
public void Four_in_order_but_not_a_little_straight()
133134
{
134-
Assert.Equal(0, YachtGame.Score(new[] { 1, 1, 2, 3, 4 }, YachtCategory.LittleStraight));
135+
Assert.Equal(0, YachtGame.Score([1, 1, 2, 3, 4], YachtCategory.LittleStraight));
135136
}
136137

137138
[Fact(Skip = "Remove this Skip property to run this test")]
138139
public void No_pairs_but_not_a_little_straight()
139140
{
140-
Assert.Equal(0, YachtGame.Score(new[] { 1, 2, 3, 4, 6 }, YachtCategory.LittleStraight));
141+
Assert.Equal(0, YachtGame.Score([1, 2, 3, 4, 6], YachtCategory.LittleStraight));
141142
}
142143

143144
[Fact(Skip = "Remove this Skip property to run this test")]
144145
public void Minimum_is_1_maximum_is_5_but_not_a_little_straight()
145146
{
146-
Assert.Equal(0, YachtGame.Score(new[] { 1, 1, 3, 4, 5 }, YachtCategory.LittleStraight));
147+
Assert.Equal(0, YachtGame.Score([1, 1, 3, 4, 5], YachtCategory.LittleStraight));
147148
}
148149

149150
[Fact(Skip = "Remove this Skip property to run this test")]
150151
public void Big_straight()
151152
{
152-
Assert.Equal(30, YachtGame.Score(new[] { 4, 6, 2, 5, 3 }, YachtCategory.BigStraight));
153+
Assert.Equal(30, YachtGame.Score([4, 6, 2, 5, 3], YachtCategory.BigStraight));
153154
}
154155

155156
[Fact(Skip = "Remove this Skip property to run this test")]
156157
public void Big_straight_as_little_straight()
157158
{
158-
Assert.Equal(0, YachtGame.Score(new[] { 6, 5, 4, 3, 2 }, YachtCategory.LittleStraight));
159+
Assert.Equal(0, YachtGame.Score([6, 5, 4, 3, 2], YachtCategory.LittleStraight));
159160
}
160161

161162
[Fact(Skip = "Remove this Skip property to run this test")]
162163
public void No_pairs_but_not_a_big_straight()
163164
{
164-
Assert.Equal(0, YachtGame.Score(new[] { 6, 5, 4, 3, 1 }, YachtCategory.BigStraight));
165+
Assert.Equal(0, YachtGame.Score([6, 5, 4, 3, 1], YachtCategory.BigStraight));
165166
}
166167

167168
[Fact(Skip = "Remove this Skip property to run this test")]
168169
public void Choice()
169170
{
170-
Assert.Equal(23, YachtGame.Score(new[] { 3, 3, 5, 6, 6 }, YachtCategory.Choice));
171+
Assert.Equal(23, YachtGame.Score([3, 3, 5, 6, 6], YachtCategory.Choice));
171172
}
172173

173174
[Fact(Skip = "Remove this Skip property to run this test")]
174175
public void Yacht_as_choice()
175176
{
176-
Assert.Equal(10, YachtGame.Score(new[] { 2, 2, 2, 2, 2 }, YachtCategory.Choice));
177+
Assert.Equal(10, YachtGame.Score([2, 2, 2, 2, 2], YachtCategory.Choice));
177178
}
178179
}

generators.deprecated/Exercises/Generators/Yacht.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)