Skip to content

Commit 6f0a3d7

Browse files
Add eliuds-eggs
1 parent 877513b commit 6f0a3d7

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Xunit;
2+
3+
public class EliudsEggsTests
4+
{
5+
{{#test_cases}}
6+
[Fact{{#unless @first}}(Skip = "Remove this Skip property to run this test"){{/unless}}]
7+
public void {{method_name path}}()
8+
{
9+
Assert.Equal({{expected}}, EliudsEggs.EggCount({{input.number}}));
10+
}
11+
{{/test_cases}}
12+
}

exercises/practice/eliuds-eggs/EliudsEggsTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
public class EliudsEggsTests
44
{
55
[Fact]
6-
public void Number_0_eggs()
6+
public void ZeroEggs()
77
{
88
Assert.Equal(0, EliudsEggs.EggCount(0));
99
}
1010

1111
[Fact(Skip = "Remove this Skip property to run this test")]
12-
public void Number_1_egg()
12+
public void OneEgg()
1313
{
1414
Assert.Equal(1, EliudsEggs.EggCount(16));
1515
}
1616

1717
[Fact(Skip = "Remove this Skip property to run this test")]
18-
public void Number_4_eggs()
18+
public void FourEggs()
1919
{
2020
Assert.Equal(4, EliudsEggs.EggCount(89));
2121
}
2222

2323
[Fact(Skip = "Remove this Skip property to run this test")]
24-
public void Number_13_eggs()
24+
public void ThirteenEggs()
2525
{
2626
Assert.Equal(13, EliudsEggs.EggCount(2000000000));
2727
}

generators.new/Templates.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ static Templates()
1919
HandlebarsHelpers.Register(HandlebarsContext, options => { options.UseCategoryPrefix = false; });
2020
HandlebarsContext.RegisterHelper("method_name", (writer, context, parameters) =>
2121
{
22-
var path = parameters.SelectMany(parameter => parameter as IEnumerable<string> ?? [parameter.ToString()!]);
22+
var path = parameters.SelectMany(parameter => parameter as IEnumerable<string> ?? [parameter.ToString()!]).ToArray();
23+
24+
// Fix method names that start with a number
25+
if (char.IsNumber(path[0][0]))
26+
{
27+
var parts = path[0].Split(' ');
28+
path[0] = string.Join(" ", [Convert.ToInt32(parts[0]).ToWords(), ..parts[1..]]);
29+
}
30+
2331
writer.WriteSafeString(string.Join(" ", path).Dehumanize());
2432
});
2533
HandlebarsContext.RegisterHelper("raw", (writer, context, parameters) =>

0 commit comments

Comments
 (0)