Skip to content

Commit c4d720c

Browse files
committed
Merge pull request #9 from jwood803/twelve-days
Added twelve days exercise
2 parents 8ca159b + e7f7548 commit c4d720c

File tree

3 files changed

+194
-0
lines changed

3 files changed

+194
-0
lines changed

EXERCISES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ phone-number
1010
robot-name
1111
sum-of-multiples
1212
meetup
13+
twelve-days

twelve-days/Example.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
public class TwelveDaysSong
8+
{
9+
public string Sing()
10+
{
11+
return Verses(1, 12);
12+
}
13+
14+
public string Verse(int verseNumber)
15+
{
16+
switch(verseNumber)
17+
{
18+
case 1:
19+
return "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.\n";
20+
case 2:
21+
return "On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.\n";
22+
case 3:
23+
return "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";
24+
case 4:
25+
return "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";
26+
case 5:
27+
return "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";
28+
case 6:
29+
return "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.\n";
30+
case 7:
31+
return "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.\n";
32+
case 8:
33+
return "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.\n";
34+
case 9:
35+
return "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.\n";
36+
case 10:
37+
return "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.\n";
38+
case 11:
39+
return "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.\n";
40+
case 12:
41+
return "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.\n";
42+
default:
43+
return "";
44+
}
45+
}
46+
47+
public string Verses(int start, int end)
48+
{
49+
var stringBuilder = new StringBuilder();
50+
51+
Enumerable.Range(start, end).ToList().ForEach(i => stringBuilder.Append(Verse(i)).Append("\n"));
52+
53+
return stringBuilder.ToString();
54+
}
55+
}

twelve-days/TwelveDaysTest.cs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using NUnit.Framework;
2+
3+
[TestFixture]
4+
public class TwelveDaysTest
5+
{
6+
private TwelveDaysSong twelveDaysSong;
7+
8+
[SetUp]
9+
public void Setup()
10+
{
11+
twelveDaysSong = new TwelveDaysSong();
12+
}
13+
14+
[Test]
15+
public void Return_Verse_1()
16+
{
17+
var expected = "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.\n";
18+
19+
Assert.That(twelveDaysSong.Verse(1), Is.EqualTo(expected));
20+
}
21+
22+
[Test]
23+
[Ignore]
24+
public void Return_Verse_2()
25+
{
26+
var expected = "On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.\n";
27+
28+
Assert.That(twelveDaysSong.Verse(2), Is.EqualTo(expected));
29+
}
30+
31+
[Test]
32+
[Ignore]
33+
public void Return_Verse_3()
34+
{
35+
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.\n";
36+
37+
Assert.That(twelveDaysSong.Verse(3), Is.EqualTo(expected));
38+
}
39+
40+
[Test]
41+
[Ignore]
42+
public void Return_Verse_4()
43+
{
44+
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";
45+
46+
Assert.That(twelveDaysSong.Verse(4), Is.EqualTo(expected));
47+
}
48+
49+
[Test]
50+
[Ignore]
51+
public void Return_Verse_5()
52+
{
53+
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.\n";
54+
55+
Assert.That(twelveDaysSong.Verse(5), Is.EqualTo(expected));
56+
}
57+
58+
[Test]
59+
[Ignore]
60+
public void Return_Verse_6()
61+
{
62+
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.\n";
63+
64+
Assert.That(twelveDaysSong.Verse(6), Is.EqualTo(expected));
65+
}
66+
67+
[Test]
68+
[Ignore]
69+
public void Return_Verse_7()
70+
{
71+
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.\n";
72+
73+
Assert.That(twelveDaysSong.Verse(7), Is.EqualTo(expected));
74+
}
75+
76+
[Test]
77+
[Ignore]
78+
public void Return_Verse_8()
79+
{
80+
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.\n";
81+
82+
Assert.That(twelveDaysSong.Verse(8), Is.EqualTo(expected));
83+
}
84+
85+
[Test]
86+
[Ignore]
87+
public void Return_Verse_9()
88+
{
89+
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.\n";
90+
91+
Assert.That(twelveDaysSong.Verse(9), Is.EqualTo(expected));
92+
}
93+
94+
[Test]
95+
[Ignore]
96+
public void Return_Verse_10()
97+
{
98+
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.\n";
99+
100+
Assert.That(twelveDaysSong.Verse(10), Is.EqualTo(expected));
101+
}
102+
103+
[Test]
104+
[Ignore]
105+
public void Return_Verse_11()
106+
{
107+
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.\n";
108+
109+
Assert.That(twelveDaysSong.Verse(11), Is.EqualTo(expected));
110+
}
111+
112+
[Test]
113+
[Ignore]
114+
public void Return_Verse_12()
115+
{
116+
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.\n";
117+
118+
Assert.That(twelveDaysSong.Verse(12), Is.EqualTo(expected));
119+
}
120+
121+
[Test]
122+
[Ignore]
123+
public void Return_Multiple_Verses()
124+
{
125+
var expected = "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.\n\n" +
126+
"On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.\n\n" +
127+
"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\n";
128+
129+
Assert.That(twelveDaysSong.Verses(1, 3), Is.EqualTo(expected));
130+
}
131+
132+
[Test]
133+
[Ignore]
134+
public void Return_Entire_Song()
135+
{
136+
Assert.That(twelveDaysSong.Verses(1, 12), Is.EqualTo(twelveDaysSong.Sing()));
137+
}
138+
}

0 commit comments

Comments
 (0)