Skip to content

Commit 7432aec

Browse files
Encore (#2372)
* Minor fix * proverb: add generator * Add songs * transpose: add generator * Fix multiline strings [no important files changed]
1 parent a5149b0 commit 7432aec

File tree

15 files changed

+235
-205
lines changed

15 files changed

+235
-205
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
var expected =
10+
{{- for line in test.expected }}
11+
{{ if for.last -}}
12+
{{ line | string.literal -}};
13+
{{- else -}}
14+
{{ line | string.append "\n" | string.literal }} +
15+
{{- end -}}
16+
{{- end }}
17+
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.startVerse }}{{if test.input.endVerse != test.input.startVerse }}, {{ test.input.endVerse }}{{ end }}));
18+
}
19+
{{ end -}}
20+
}

exercises/practice/food-chain/FoodChainTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class FoodChainTests
55
[Fact]
66
public void Fly()
77
{
8-
var expected =
8+
var expected =
99
"I know an old lady who swallowed a fly.\n" +
1010
"I don't know why she swallowed the fly. Perhaps she'll die.";
1111
Assert.Equal(expected, FoodChain.Recite(1));
@@ -14,7 +14,7 @@ public void Fly()
1414
[Fact(Skip = "Remove this Skip property to run this test")]
1515
public void Spider()
1616
{
17-
var expected =
17+
var expected =
1818
"I know an old lady who swallowed a spider.\n" +
1919
"It wriggled and jiggled and tickled inside her.\n" +
2020
"She swallowed the spider to catch the fly.\n" +
@@ -25,7 +25,7 @@ public void Spider()
2525
[Fact(Skip = "Remove this Skip property to run this test")]
2626
public void Bird()
2727
{
28-
var expected =
28+
var expected =
2929
"I know an old lady who swallowed a bird.\n" +
3030
"How absurd to swallow a bird!\n" +
3131
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
@@ -37,7 +37,7 @@ public void Bird()
3737
[Fact(Skip = "Remove this Skip property to run this test")]
3838
public void Cat()
3939
{
40-
var expected =
40+
var expected =
4141
"I know an old lady who swallowed a cat.\n" +
4242
"Imagine that, to swallow a cat!\n" +
4343
"She swallowed the cat to catch the bird.\n" +
@@ -50,7 +50,7 @@ public void Cat()
5050
[Fact(Skip = "Remove this Skip property to run this test")]
5151
public void Dog()
5252
{
53-
var expected =
53+
var expected =
5454
"I know an old lady who swallowed a dog.\n" +
5555
"What a hog, to swallow a dog!\n" +
5656
"She swallowed the dog to catch the cat.\n" +
@@ -64,7 +64,7 @@ public void Dog()
6464
[Fact(Skip = "Remove this Skip property to run this test")]
6565
public void Goat()
6666
{
67-
var expected =
67+
var expected =
6868
"I know an old lady who swallowed a goat.\n" +
6969
"Just opened her throat and swallowed a goat!\n" +
7070
"She swallowed the goat to catch the dog.\n" +
@@ -79,7 +79,7 @@ public void Goat()
7979
[Fact(Skip = "Remove this Skip property to run this test")]
8080
public void Cow()
8181
{
82-
var expected =
82+
var expected =
8383
"I know an old lady who swallowed a cow.\n" +
8484
"I don't know how she swallowed a cow!\n" +
8585
"She swallowed the cow to catch the goat.\n" +
@@ -95,7 +95,7 @@ public void Cow()
9595
[Fact(Skip = "Remove this Skip property to run this test")]
9696
public void Horse()
9797
{
98-
var expected =
98+
var expected =
9999
"I know an old lady who swallowed a horse.\n" +
100100
"She's dead, of course!";
101101
Assert.Equal(expected, FoodChain.Recite(8));
@@ -104,7 +104,7 @@ public void Horse()
104104
[Fact(Skip = "Remove this Skip property to run this test")]
105105
public void Multiple_verses()
106106
{
107-
var expected =
107+
var expected =
108108
"I know an old lady who swallowed a fly.\n" +
109109
"I don't know why she swallowed the fly. Perhaps she'll die.\n" +
110110
"\n" +
@@ -124,7 +124,7 @@ public void Multiple_verses()
124124
[Fact(Skip = "Remove this Skip property to run this test")]
125125
public void Full_song()
126126
{
127-
var expected =
127+
var expected =
128128
"I know an old lady who swallowed a fly.\n" +
129129
"I don't know why she swallowed the fly. Perhaps she'll die.\n" +
130130
"\n" +
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
var expected =
10+
{{- for line in test.expected }}
11+
{{ if for.last -}}
12+
{{ line | string.literal -}};
13+
{{- else -}}
14+
{{ line | string.append "\n" | string.literal }} +
15+
{{- end -}}
16+
{{- end }}
17+
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.startVerse }}{{if test.input.endVerse != test.input.startVerse }}, {{ test.input.endVerse }}{{ end }}));
18+
}
19+
{{ end -}}
20+
}

exercises/practice/house/HouseTests.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,103 @@ public class HouseTests
55
[Fact]
66
public void Verse_one_the_house_that_jack_built()
77
{
8-
var expected = "This is the house that Jack built.";
8+
var expected =
9+
"This is the house that Jack built.";
910
Assert.Equal(expected, House.Recite(1));
1011
}
1112

1213
[Fact(Skip = "Remove this Skip property to run this test")]
1314
public void Verse_two_the_malt_that_lay()
1415
{
15-
var expected = "This is the malt that lay in the house that Jack built.";
16+
var expected =
17+
"This is the malt that lay in the house that Jack built.";
1618
Assert.Equal(expected, House.Recite(2));
1719
}
1820

1921
[Fact(Skip = "Remove this Skip property to run this test")]
2022
public void Verse_three_the_rat_that_ate()
2123
{
22-
var expected = "This is the rat that ate the malt that lay in the house that Jack built.";
24+
var expected =
25+
"This is the rat that ate the malt that lay in the house that Jack built.";
2326
Assert.Equal(expected, House.Recite(3));
2427
}
2528

2629
[Fact(Skip = "Remove this Skip property to run this test")]
2730
public void Verse_four_the_cat_that_killed()
2831
{
29-
var expected = "This is the cat that killed the rat that ate the malt that lay in the house that Jack built.";
32+
var expected =
33+
"This is the cat that killed the rat that ate the malt that lay in the house that Jack built.";
3034
Assert.Equal(expected, House.Recite(4));
3135
}
3236

3337
[Fact(Skip = "Remove this Skip property to run this test")]
3438
public void Verse_five_the_dog_that_worried()
3539
{
36-
var expected = "This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
40+
var expected =
41+
"This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
3742
Assert.Equal(expected, House.Recite(5));
3843
}
3944

4045
[Fact(Skip = "Remove this Skip property to run this test")]
4146
public void Verse_six_the_cow_with_the_crumpled_horn()
4247
{
43-
var expected = "This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
48+
var expected =
49+
"This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
4450
Assert.Equal(expected, House.Recite(6));
4551
}
4652

4753
[Fact(Skip = "Remove this Skip property to run this test")]
4854
public void Verse_seven_the_maiden_all_forlorn()
4955
{
50-
var expected = "This is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
56+
var expected =
57+
"This is the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
5158
Assert.Equal(expected, House.Recite(7));
5259
}
5360

5461
[Fact(Skip = "Remove this Skip property to run this test")]
5562
public void Verse_eight_the_man_all_tattered_and_torn()
5663
{
57-
var expected = "This is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
64+
var expected =
65+
"This is the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
5866
Assert.Equal(expected, House.Recite(8));
5967
}
6068

6169
[Fact(Skip = "Remove this Skip property to run this test")]
6270
public void Verse_nine_the_priest_all_shaven_and_shorn()
6371
{
64-
var expected = "This is the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
72+
var expected =
73+
"This is the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
6574
Assert.Equal(expected, House.Recite(9));
6675
}
6776

6877
[Fact(Skip = "Remove this Skip property to run this test")]
6978
public void Verse_10_the_rooster_that_crowed_in_the_morn()
7079
{
71-
var expected = "This is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
80+
var expected =
81+
"This is the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
7282
Assert.Equal(expected, House.Recite(10));
7383
}
7484

7585
[Fact(Skip = "Remove this Skip property to run this test")]
7686
public void Verse_11_the_farmer_sowing_his_corn()
7787
{
78-
var expected = "This is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
88+
var expected =
89+
"This is the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
7990
Assert.Equal(expected, House.Recite(11));
8091
}
8192

8293
[Fact(Skip = "Remove this Skip property to run this test")]
8394
public void Verse_12_the_horse_and_the_hound_and_the_horn()
8495
{
85-
var expected = "This is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
96+
var expected =
97+
"This is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.";
8698
Assert.Equal(expected, House.Recite(12));
8799
}
88100

89101
[Fact(Skip = "Remove this Skip property to run this test")]
90102
public void Multiple_verses()
91103
{
92-
var expected =
104+
var expected =
93105
"This is the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" +
94106
"This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" +
95107
"This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" +
@@ -101,7 +113,7 @@ public void Multiple_verses()
101113
[Fact(Skip = "Remove this Skip property to run this test")]
102114
public void Full_rhyme()
103115
{
104-
var expected =
116+
var expected =
105117
"This is the house that Jack built.\n" +
106118
"This is the malt that lay in the house that Jack built.\n" +
107119
"This is the rat that ate the malt that lay in the house that Jack built.\n" +
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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[] subjects = {{ test.input.strings }};
10+
string[] expected = [
11+
{{- for line in test.expected }}
12+
{{ line | string.literal }}{{- if !for.last }},{{ end -}}
13+
{{ end }}
14+
];
15+
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}(subjects));
16+
}
17+
{{ end -}}
18+
}

0 commit comments

Comments
 (0)