Skip to content
Merged

Encore #2372

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions exercises/practice/food-chain/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Xunit;

public class {{ testClass }}
{
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
var expected =
{{- for line in test.expected }}
{{ if for.last -}}
{{ line | string.literal -}};
{{- else -}}
{{ line | string.append "\n" | string.literal }} +
{{- end -}}
{{- end }}
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.startVerse }}{{if test.input.endVerse != test.input.startVerse }}, {{ test.input.endVerse }}{{ end }}));
}
{{ end -}}
}
20 changes: 10 additions & 10 deletions exercises/practice/food-chain/FoodChainTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class FoodChainTests
[Fact]
public void Fly()
{
var expected =
var expected =
"I know an old lady who swallowed a fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Recite(1));
Expand All @@ -14,7 +14,7 @@ public void Fly()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Spider()
{
var expected =
var expected =
"I know an old lady who swallowed a spider.\n" +
"It wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
Expand All @@ -25,7 +25,7 @@ public void Spider()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Bird()
{
var expected =
var expected =
"I know an old lady who swallowed a bird.\n" +
"How absurd to swallow a bird!\n" +
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
Expand All @@ -37,7 +37,7 @@ public void Bird()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Cat()
{
var expected =
var expected =
"I know an old lady who swallowed a cat.\n" +
"Imagine that, to swallow a cat!\n" +
"She swallowed the cat to catch the bird.\n" +
Expand All @@ -50,7 +50,7 @@ public void Cat()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Dog()
{
var expected =
var expected =
"I know an old lady who swallowed a dog.\n" +
"What a hog, to swallow a dog!\n" +
"She swallowed the dog to catch the cat.\n" +
Expand All @@ -64,7 +64,7 @@ public void Dog()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Goat()
{
var expected =
var expected =
"I know an old lady who swallowed a goat.\n" +
"Just opened her throat and swallowed a goat!\n" +
"She swallowed the goat to catch the dog.\n" +
Expand All @@ -79,7 +79,7 @@ public void Goat()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Cow()
{
var expected =
var expected =
"I know an old lady who swallowed a cow.\n" +
"I don't know how she swallowed a cow!\n" +
"She swallowed the cow to catch the goat.\n" +
Expand All @@ -95,7 +95,7 @@ public void Cow()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Horse()
{
var expected =
var expected =
"I know an old lady who swallowed a horse.\n" +
"She's dead, of course!";
Assert.Equal(expected, FoodChain.Recite(8));
Expand All @@ -104,7 +104,7 @@ public void Horse()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Multiple_verses()
{
var expected =
var expected =
"I know an old lady who swallowed a fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.\n" +
"\n" +
Expand All @@ -124,7 +124,7 @@ public void Multiple_verses()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Full_song()
{
var expected =
var expected =
"I know an old lady who swallowed a fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.\n" +
"\n" +
Expand Down
20 changes: 20 additions & 0 deletions exercises/practice/house/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Xunit;

public class {{ testClass }}
{
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
var expected =
{{- for line in test.expected }}
{{ if for.last -}}
{{ line | string.literal -}};
{{- else -}}
{{ line | string.append "\n" | string.literal }} +
{{- end -}}
{{- end }}
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.startVerse }}{{if test.input.endVerse != test.input.startVerse }}, {{ test.input.endVerse }}{{ end }}));
}
{{ end -}}
}
40 changes: 26 additions & 14 deletions exercises/practice/house/HouseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,91 +5,103 @@ public class HouseTests
[Fact]
public void Verse_one_the_house_that_jack_built()
{
var expected = "This is the house that Jack built.";
var expected =
"This is the house that Jack built.";
Assert.Equal(expected, House.Recite(1));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_two_the_malt_that_lay()
{
var expected = "This is the malt that lay in the house that Jack built.";
var expected =
"This is the malt that lay in the house that Jack built.";
Assert.Equal(expected, House.Recite(2));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_three_the_rat_that_ate()
{
var expected = "This is the rat that ate the malt that lay in the house that Jack built.";
var expected =
"This is the rat that ate the malt that lay in the house that Jack built.";
Assert.Equal(expected, House.Recite(3));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_four_the_cat_that_killed()
{
var expected = "This is the cat that killed the rat that ate the malt that lay in the house that Jack built.";
var expected =
"This is the cat that killed the rat that ate the malt that lay in the house that Jack built.";
Assert.Equal(expected, House.Recite(4));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_five_the_dog_that_worried()
{
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.";
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.";
Assert.Equal(expected, House.Recite(5));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_six_the_cow_with_the_crumpled_horn()
{
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.";
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.";
Assert.Equal(expected, House.Recite(6));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_seven_the_maiden_all_forlorn()
{
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.";
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.";
Assert.Equal(expected, House.Recite(7));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_eight_the_man_all_tattered_and_torn()
{
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.";
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.";
Assert.Equal(expected, House.Recite(8));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_nine_the_priest_all_shaven_and_shorn()
{
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.";
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.";
Assert.Equal(expected, House.Recite(9));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_10_the_rooster_that_crowed_in_the_morn()
{
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.";
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.";
Assert.Equal(expected, House.Recite(10));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_11_the_farmer_sowing_his_corn()
{
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.";
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.";
Assert.Equal(expected, House.Recite(11));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Verse_12_the_horse_and_the_hound_and_the_horn()
{
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.";
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.";
Assert.Equal(expected, House.Recite(12));
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void Multiple_verses()
{
var expected =
var expected =
"This is the cat that killed the rat that ate the malt that lay in the house that Jack built.\n" +
"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" +
"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" +
Expand All @@ -101,7 +113,7 @@ public void Multiple_verses()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Full_rhyme()
{
var expected =
var expected =
"This is the house that Jack built.\n" +
"This is the malt that lay in the house that Jack built.\n" +
"This is the rat that ate the malt that lay in the house that Jack built.\n" +
Expand Down
18 changes: 18 additions & 0 deletions exercises/practice/proverb/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Xunit;

public class {{ testClass }}
{
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
string[] subjects = {{ test.input.strings }};
string[] expected = [
{{- for line in test.expected }}
{{ line | string.literal }}{{- if !for.last }},{{ end -}}
{{ end }}
];
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}(subjects));
}
{{ end -}}
}
Loading
Loading