diff --git a/exercises/practice/food-chain/.meta/Generator.tpl b/exercises/practice/food-chain/.meta/Generator.tpl new file mode 100644 index 0000000000..74df0e50bd --- /dev/null +++ b/exercises/practice/food-chain/.meta/Generator.tpl @@ -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 -}} +} diff --git a/exercises/practice/food-chain/FoodChainTests.cs b/exercises/practice/food-chain/FoodChainTests.cs index fc40680081..7f2dd563b5 100644 --- a/exercises/practice/food-chain/FoodChainTests.cs +++ b/exercises/practice/food-chain/FoodChainTests.cs @@ -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)); @@ -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" + @@ -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" + @@ -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" + @@ -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" + @@ -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" + @@ -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" + @@ -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)); @@ -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" + @@ -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" + diff --git a/exercises/practice/house/.meta/Generator.tpl b/exercises/practice/house/.meta/Generator.tpl new file mode 100644 index 0000000000..74df0e50bd --- /dev/null +++ b/exercises/practice/house/.meta/Generator.tpl @@ -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 -}} +} diff --git a/exercises/practice/house/HouseTests.cs b/exercises/practice/house/HouseTests.cs index 7338e1db45..d0b8dbdf81 100644 --- a/exercises/practice/house/HouseTests.cs +++ b/exercises/practice/house/HouseTests.cs @@ -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" + @@ -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" + diff --git a/exercises/practice/proverb/.meta/Generator.tpl b/exercises/practice/proverb/.meta/Generator.tpl new file mode 100644 index 0000000000..3f03175db0 --- /dev/null +++ b/exercises/practice/proverb/.meta/Generator.tpl @@ -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 -}} +} diff --git a/exercises/practice/proverb/ProverbTests.cs b/exercises/practice/proverb/ProverbTests.cs index 648d459b16..6e0a72ddd5 100644 --- a/exercises/practice/proverb/ProverbTests.cs +++ b/exercises/practice/proverb/ProverbTests.cs @@ -1,4 +1,3 @@ -using System; using Xunit; public class ProverbTests @@ -6,74 +5,50 @@ public class ProverbTests [Fact] public void Zero_pieces() { - var strings = Array.Empty(); - var expected = Array.Empty(); - Assert.Equal(expected, Proverb.Recite(strings)); + string[] subjects = []; + string[] expected = [ + ]; + Assert.Equal(expected, Proverb.Recite(subjects)); } [Fact(Skip = "Remove this Skip property to run this test")] public void One_piece() { - var strings = new[] - { - "nail" - }; - var expected = new[] - { + string[] subjects = ["nail"]; + string[] expected = [ "And all for the want of a nail." - }; - Assert.Equal(expected, Proverb.Recite(strings)); + ]; + Assert.Equal(expected, Proverb.Recite(subjects)); } [Fact(Skip = "Remove this Skip property to run this test")] public void Two_pieces() { - var strings = new[] - { - "nail", - "shoe" - }; - var expected = new[] - { + string[] subjects = ["nail", "shoe"]; + string[] expected = [ "For want of a nail the shoe was lost.", "And all for the want of a nail." - }; - Assert.Equal(expected, Proverb.Recite(strings)); + ]; + Assert.Equal(expected, Proverb.Recite(subjects)); } [Fact(Skip = "Remove this Skip property to run this test")] public void Three_pieces() { - var strings = new[] - { - "nail", - "shoe", - "horse" - }; - var expected = new[] - { + string[] subjects = ["nail", "shoe", "horse"]; + string[] expected = [ "For want of a nail the shoe was lost.", "For want of a shoe the horse was lost.", "And all for the want of a nail." - }; - Assert.Equal(expected, Proverb.Recite(strings)); + ]; + Assert.Equal(expected, Proverb.Recite(subjects)); } [Fact(Skip = "Remove this Skip property to run this test")] public void Full_proverb() { - var strings = new[] - { - "nail", - "shoe", - "horse", - "rider", - "message", - "battle", - "kingdom" - }; - var expected = new[] - { + string[] subjects = ["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]; + string[] expected = [ "For want of a nail the shoe was lost.", "For want of a shoe the horse was lost.", "For want of a horse the rider was lost.", @@ -81,27 +56,20 @@ public void Full_proverb() "For want of a message the battle was lost.", "For want of a battle the kingdom was lost.", "And all for the want of a nail." - }; - Assert.Equal(expected, Proverb.Recite(strings)); + ]; + Assert.Equal(expected, Proverb.Recite(subjects)); } [Fact(Skip = "Remove this Skip property to run this test")] public void Four_pieces_modernized() { - var strings = new[] - { - "pin", - "gun", - "soldier", - "battle" - }; - var expected = new[] - { + string[] subjects = ["pin", "gun", "soldier", "battle"]; + string[] expected = [ "For want of a pin the gun was lost.", "For want of a gun the soldier was lost.", "For want of a soldier the battle was lost.", "And all for the want of a pin." - }; - Assert.Equal(expected, Proverb.Recite(strings)); + ]; + Assert.Equal(expected, Proverb.Recite(subjects)); } } diff --git a/exercises/practice/transpose/.meta/Generator.tpl b/exercises/practice/transpose/.meta/Generator.tpl new file mode 100644 index 0000000000..ef2159b193 --- /dev/null +++ b/exercises/practice/transpose/.meta/Generator.tpl @@ -0,0 +1,29 @@ +{{ func lines(lines, variable) }} + {{- if test.input.lines.empty? }} + var {{variable}} = ""; + {{- else }} + var {{variable}} = + {{- for line in lines }} + {{ if for.last -}} + {{ line | string.literal -}}; + {{- else -}} + {{ line | string.append "\n" | string.literal }} + + {{- end -}} + {{- end }} + {{- end -}} +{{ end }} + +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 }}() + { + {{- test.input.lines | lines "lines" }} + {{- test.expected | lines "expected" }} + Assert.Equal(expected, {{ testedClass }}.String(lines)); + } + {{ end -}} +} diff --git a/exercises/practice/transpose/TransposeTests.cs b/exercises/practice/transpose/TransposeTests.cs index 67f78a4b94..abb815050b 100644 --- a/exercises/practice/transpose/TransposeTests.cs +++ b/exercises/practice/transpose/TransposeTests.cs @@ -13,8 +13,9 @@ public void Empty_string() [Fact(Skip = "Remove this Skip property to run this test")] public void Two_characters_in_a_row() { - var lines = "A1"; - var expected = + var lines = + "A1"; + var expected = "A\n" + "1"; Assert.Equal(expected, Transpose.String(lines)); @@ -23,20 +24,21 @@ public void Two_characters_in_a_row() [Fact(Skip = "Remove this Skip property to run this test")] public void Two_characters_in_a_column() { - var lines = + var lines = "A\n" + "1"; - var expected = "A1"; + var expected = + "A1"; Assert.Equal(expected, Transpose.String(lines)); } [Fact(Skip = "Remove this Skip property to run this test")] public void Simple() { - var lines = + var lines = "ABC\n" + "123"; - var expected = + var expected = "A1\n" + "B2\n" + "C3"; @@ -46,8 +48,9 @@ public void Simple() [Fact(Skip = "Remove this Skip property to run this test")] public void Single_line() { - var lines = "Single line."; - var expected = + var lines = + "Single line."; + var expected = "S\n" + "i\n" + "n\n" + @@ -66,10 +69,10 @@ public void Single_line() [Fact(Skip = "Remove this Skip property to run this test")] public void First_line_longer_than_second_line() { - var lines = + var lines = "The fourth line.\n" + "The fifth line."; - var expected = + var expected = "TT\n" + "hh\n" + "ee\n" + @@ -92,10 +95,10 @@ public void First_line_longer_than_second_line() [Fact(Skip = "Remove this Skip property to run this test")] public void Second_line_longer_than_first_line() { - var lines = + var lines = "The first line.\n" + "The second line."; - var expected = + var expected = "TT\n" + "hh\n" + "ee\n" + @@ -118,12 +121,12 @@ public void Second_line_longer_than_first_line() [Fact(Skip = "Remove this Skip property to run this test")] public void Mixed_line_length() { - var lines = + var lines = "The longest line.\n" + "A long line.\n" + "A longer line.\n" + "A line."; - var expected = + var expected = "TAAA\n" + "h \n" + "elll\n" + @@ -147,13 +150,13 @@ public void Mixed_line_length() [Fact(Skip = "Remove this Skip property to run this test")] public void Square() { - var lines = + var lines = "HEART\n" + "EMBER\n" + "ABUSE\n" + "RESIN\n" + "TREND"; - var expected = + var expected = "HEART\n" + "EMBER\n" + "ABUSE\n" + @@ -165,12 +168,12 @@ public void Square() [Fact(Skip = "Remove this Skip property to run this test")] public void Rectangle() { - var lines = + var lines = "FRACTURE\n" + "OUTLINED\n" + "BLOOMING\n" + "SEPTETTE"; - var expected = + var expected = "FOBS\n" + "RULE\n" + "ATOP\n" + @@ -185,14 +188,14 @@ public void Rectangle() [Fact(Skip = "Remove this Skip property to run this test")] public void Triangle() { - var lines = + var lines = "T\n" + "EE\n" + "AAA\n" + "SSSS\n" + "EEEEE\n" + "RRRRRR"; - var expected = + var expected = "TEASER\n" + " EASER\n" + " ASER\n" + @@ -205,14 +208,14 @@ public void Triangle() [Fact(Skip = "Remove this Skip property to run this test")] public void Jagged_triangle() { - var lines = + var lines = "11\n" + "2\n" + "3333\n" + "444\n" + "555555\n" + "66666"; - var expected = + var expected = "123456\n" + "1 3456\n" + " 3456\n" + diff --git a/exercises/practice/twelve-days/.meta/Generator.tpl b/exercises/practice/twelve-days/.meta/Generator.tpl new file mode 100644 index 0000000000..74df0e50bd --- /dev/null +++ b/exercises/practice/twelve-days/.meta/Generator.tpl @@ -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 -}} +} diff --git a/exercises/practice/twelve-days/TwelveDaysTests.cs b/exercises/practice/twelve-days/TwelveDaysTests.cs index a2c6dca7af..b4a687628f 100644 --- a/exercises/practice/twelve-days/TwelveDaysTests.cs +++ b/exercises/practice/twelve-days/TwelveDaysTests.cs @@ -3,93 +3,105 @@ public class TwelveDaysTests { [Fact] - public void First_day_a_partridge_in_a_pear_tree() + public void Verse_first_day_a_partridge_in_a_pear_tree() { - var expected = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree."; + var expected = + "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(1)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Second_day_two_turtle_doves() + public void Verse_second_day_two_turtle_doves() { - var expected = "On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(2)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Third_day_three_french_hens() + public void Verse_third_day_three_french_hens() { - var expected = "On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(3)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Fourth_day_four_calling_birds() + public void Verse_fourth_day_four_calling_birds() { - var expected = "On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(4)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Fifth_day_five_gold_rings() + public void Verse_fifth_day_five_gold_rings() { - var expected = "On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(5)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Sixth_day_six_geese_a_laying() + public void Verse_sixth_day_six_geese_a_laying() { - var expected = "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(6)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Seventh_day_seven_swans_a_swimming() + public void Verse_seventh_day_seven_swans_a_swimming() { - var expected = "On the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(7)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Eighth_day_eight_maids_a_milking() + public void Verse_eighth_day_eight_maids_a_milking() { - var expected = "On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(8)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Ninth_day_nine_ladies_dancing() + public void Verse_ninth_day_nine_ladies_dancing() { - var expected = "On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(9)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Tenth_day_ten_lords_a_leaping() + public void Verse_tenth_day_ten_lords_a_leaping() { - var expected = "On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(10)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Eleventh_day_eleven_pipers_piping() + public void Verse_eleventh_day_eleven_pipers_piping() { - var expected = "On the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(11)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Twelfth_day_twelve_drummers_drumming() + public void Verse_twelfth_day_twelve_drummers_drumming() { - var expected = "On the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; + var expected = + "On the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; Assert.Equal(expected, TwelveDays.Recite(12)); } [Fact(Skip = "Remove this Skip property to run this test")] - public void Recites_first_three_verses_of_the_song() + public void Lyrics_recites_first_three_verses_of_the_song() { - var expected = + var expected = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.\n" + "On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree.\n" + "On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; @@ -97,9 +109,9 @@ public void Recites_first_three_verses_of_the_song() } [Fact(Skip = "Remove this Skip property to run this test")] - public void Recites_three_verses_from_the_middle_of_the_song() + public void Lyrics_recites_three_verses_from_the_middle_of_the_song() { - var expected = + var expected = "On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" + "On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" + "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; @@ -107,9 +119,9 @@ public void Recites_three_verses_from_the_middle_of_the_song() } [Fact(Skip = "Remove this Skip property to run this test")] - public void Recites_the_whole_song() + public void Lyrics_recites_the_whole_song() { - var expected = + var expected = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.\n" + "On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree.\n" + "On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" + diff --git a/generators.deprecated/Exercises/Generators/BeerSong.cs b/generators.deprecated/Exercises/Generators/BeerSong.cs deleted file mode 100644 index b76d94e05c..0000000000 --- a/generators.deprecated/Exercises/Generators/BeerSong.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Exercism.CSharp.Output; -using Exercism.CSharp.Output.Rendering; - -namespace Exercism.CSharp.Exercises.Generators; - -internal class BeerSong : ExerciseGenerator -{ - protected override void UpdateTestMethod(TestMethod testMethod) - { - testMethod.UseVariableForExpected = true; - testMethod.Expected = new MultiLineString(testMethod.Expected); - } -} \ No newline at end of file diff --git a/generators.deprecated/Exercises/Generators/FoodChain.cs b/generators.deprecated/Exercises/Generators/FoodChain.cs deleted file mode 100644 index 50e36f6fe2..0000000000 --- a/generators.deprecated/Exercises/Generators/FoodChain.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Exercism.CSharp.Output; -using Exercism.CSharp.Output.Rendering; - -namespace Exercism.CSharp.Exercises.Generators; - -internal class FoodChain : ExerciseGenerator -{ - protected override void UpdateTestMethod(TestMethod testMethod) - { - testMethod.Expected = new MultiLineString(testMethod.Expected); - testMethod.UseVariableForExpected = true; - - if (testMethod.Input["startVerse"] == testMethod.Input["endVerse"]) - { - testMethod.InputParameters = new[] { "startVerse" }; - } - } -} \ No newline at end of file diff --git a/generators.deprecated/Exercises/Generators/House.cs b/generators.deprecated/Exercises/Generators/House.cs deleted file mode 100644 index 691c36e4b6..0000000000 --- a/generators.deprecated/Exercises/Generators/House.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Exercism.CSharp.Output; -using Exercism.CSharp.Output.Rendering; - -namespace Exercism.CSharp.Exercises.Generators; - -internal class House : ExerciseGenerator -{ - protected override void UpdateTestMethod(TestMethod testMethod) - { - testMethod.UseVariableForExpected = true; - testMethod.Expected = new MultiLineString(testMethod.Expected); - - if (testMethod.Input["startVerse"] == testMethod.Input["endVerse"]) - { - testMethod.InputParameters = new[] { "startVerse" }; - } - } -} \ No newline at end of file diff --git a/generators.deprecated/Exercises/Generators/Proverb.cs b/generators.deprecated/Exercises/Generators/Proverb.cs deleted file mode 100644 index ab8d9234ed..0000000000 --- a/generators.deprecated/Exercises/Generators/Proverb.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using Exercism.CSharp.Output; -using Exercism.CSharp.Output.Rendering; - -namespace Exercism.CSharp.Exercises.Generators; - -internal class Proverb : ExerciseGenerator -{ - protected override void UpdateTestMethod(TestMethod testMethod) - { - testMethod.UseVariablesForInput = true; - testMethod.UseVariableForExpected = true; - - testMethod.Input["strings"] = RenderAsMultilineArray(testMethod.Input["strings"]); - testMethod.Expected = RenderAsMultilineArray(testMethod.Expected); - } - - private UnescapedValue RenderAsMultilineArray(dynamic value) - => new(Render.ArrayMultiLine(value as string[] ?? Array.Empty())); - - protected override void UpdateNamespaces(ISet namespaces) => namespaces.Add(typeof(Array).Namespace!); -} \ No newline at end of file diff --git a/generators/TemplateGenerator.cs b/generators/TemplateGenerator.cs index 1a56a78000..59d3078d54 100644 --- a/generators/TemplateGenerator.cs +++ b/generators/TemplateGenerator.cs @@ -80,6 +80,6 @@ public class {%{{{ testClass }}}%} {{ assert }} {{- end }} } - {%{{{end -}}}%} + {%{{{ end -}}}%} }"; } \ No newline at end of file