Skip to content

Commit 6228bfd

Browse files
committed
Making things more idiomatic for C#.
Underscores in tests are becoming more popular in .Net so made the call to prefer that to pascal casing.
1 parent 4b8b881 commit 6228bfd

12 files changed

Lines changed: 173 additions & 175 deletions

File tree

anagram/AnagramTest.cs

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,84 @@
44
public class AnagramTest
55
{
66
[Test]
7-
public void NoMatches ()
7+
public void No_matches()
88
{
9-
Anagram detector = new Anagram("diaper");
10-
string[] words = new string[] { "hello", "world", "zombies", "pants" };
11-
string[] results = new string[0];
12-
Assert.AreEqual(results, detector.Match(words));
9+
var detector = new Anagram("diaper");
10+
var words = new[] { "hello", "world", "zombies", "pants" };
11+
var results = new string[0];
12+
Assert.That(detector.Match(words), Is.EqualTo(results));
1313
}
1414

15-
1615
[Test, Ignore]
17-
public void DetectSimpleAnagram ()
16+
public void Detect_simple_anagram()
1817
{
19-
Anagram detector = new Anagram("ant");
20-
string[] words = new string[] { "tan", "stand", "at" };
21-
string[] results = new string[] { "tan" };
22-
Assert.AreEqual(results, detector.Match(words));
18+
var detector = new Anagram("ant");
19+
var words = new[] { "tan", "stand", "at" };
20+
var results = new[] { "tan" };
21+
Assert.That(detector.Match(words), Is.EqualTo(results));
2322
}
2423

2524
[Test, Ignore]
26-
public void DetectMultipleAnagrams ()
25+
public void Detect_multiple_anagrams()
2726
{
28-
Anagram detector = new Anagram("master");
29-
string[] words = new string[] { "stream", "pigeon", "maters" };
30-
string[] results = new string[] { "maters", "stream" };
31-
Assert.AreEqual(results, detector.Match(words));
27+
var detector = new Anagram("master");
28+
var words = new[] { "stream", "pigeon", "maters" };
29+
var results = new[] { "maters", "stream" };
30+
Assert.That(detector.Match(words), Is.EqualTo(results));
3231
}
3332

3433
[Test, Ignore]
35-
public void DoesNotConfuseDifferentDuplicates ()
34+
public void Does_not_confuse_different_duplicates()
3635
{
37-
Anagram detector = new Anagram("galea");
38-
string[] words = new string[] { "eagle" };
39-
string[] results = new string[0];
40-
Assert.AreEqual(results, detector.Match(words));
36+
var detector = new Anagram("galea");
37+
var words = new[] { "eagle" };
38+
var results = new string[0];
39+
Assert.That(detector.Match(words), Is.EqualTo(results));
4140
}
4241

4342
[Test, Ignore]
44-
public void IdenticalWordIsNotAnagram ()
43+
public void Identical_word_is_not_anagram()
4544
{
46-
Anagram detector = new Anagram("corn");
47-
string[] words = new string[] { "corn", "dark", "Corn", "rank", "CORN", "cron", "park" };
48-
string[] results = new string[] { "cron" };
49-
Assert.AreEqual(results, detector.Match(words));
45+
var detector = new Anagram("corn");
46+
var words = new[] { "corn", "dark", "Corn", "rank", "CORN", "cron", "park" };
47+
var results = new[] { "cron" };
48+
Assert.That(detector.Match(words), Is.EqualTo(results));
5049
}
5150

5251
[Test, Ignore]
53-
public void EliminateAnagramsWithSameChecksum ()
52+
public void Eliminate_anagrams_with_same_checksum()
5453
{
55-
Anagram detector = new Anagram("mass");
56-
string[] words = new string[] { "last" };
57-
string[] results = new string[0];
58-
Assert.AreEqual(results, detector.Match(words));
54+
var detector = new Anagram("mass");
55+
var words = new[] { "last" };
56+
var results = new string[0];
57+
Assert.That(detector.Match(words), Is.EqualTo(results));
5958
}
6059

6160
[Test, Ignore]
62-
public void EliminateAnagramSubsets ()
61+
public void Eliminate_anagram_subsets()
6362
{
64-
Anagram detector = new Anagram("good");
65-
string[] words = new string[] { "dog", "goody" };
66-
string[] results = new string[0];
67-
Assert.AreEqual(results, detector.Match(words));
63+
var detector = new Anagram("good");
64+
var words = new[] { "dog", "goody" };
65+
var results = new string[0];
66+
Assert.That(detector.Match(words), Is.EqualTo(results));
6867
}
6968

7069
[Test, Ignore]
71-
public void DetectAnagrams ()
70+
public void Detect_anagrams()
7271
{
73-
Anagram detector = new Anagram("allergy");
74-
string[] words = new string[] { "gallery", "ballerina", "regally", "clergy", "largely", "leading" };
75-
string[] results = new string[] { "gallery", "largely", "regally" };
76-
Assert.AreEqual(results, detector.Match(words));
72+
var detector = new Anagram("allergy");
73+
var words = new[] { "gallery", "ballerina", "regally", "clergy", "largely", "leading" };
74+
var results = new[] { "gallery", "largely", "regally" };
75+
Assert.That(detector.Match(words), Is.EqualTo(results));
7776
}
7877

7978
[Test, Ignore]
80-
public void AnagramsAreCaseInsensitive ()
79+
public void Anagrams_are_case_insensitive()
8180
{
82-
Anagram detector = new Anagram("Orchestra");
83-
string[] words = new string[] { "cashregister", "Carthorse", "radishes" };
84-
string[] results = new string[] { "Carthorse" };
85-
Assert.AreEqual(results, detector.Match(words));
81+
var detector = new Anagram("Orchestra");
82+
var words = new[] { "cashregister", "Carthorse", "radishes" };
83+
var results = new[] { "Carthorse" };
84+
Assert.That(detector.Match(words), Is.EqualTo(results));
8685
}
8786

8887
}

bob/BobTest.cs

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,105 +12,104 @@ public void Init ()
1212
}
1313

1414
[Test]
15-
public void StatingSomething ()
15+
public void Stating_something ()
1616
{
17-
Assert.AreEqual("Whatever.", teenager.Hey("Tom-ay-to, tom-aaaah-to."));
17+
Assert.That(teenager.Hey("Tom-ay-to, tom-aaaah-to."), Is.EqualTo("Whatever."));
1818
}
1919

2020
[Test, Ignore]
2121
public void Shouting ()
2222
{
23-
Assert.AreEqual("Woah, chill out!", teenager.Hey("WATCH OUT!"));
23+
Assert.That(teenager.Hey("WATCH OUT!"), Is.EqualTo("Woah, chill out!"));
2424
}
2525

2626
[Test, Ignore]
27-
public void AskingAQuestion ()
27+
public void Asking_a_question ()
2828
{
29-
Assert.AreEqual("Sure.", teenager.Hey("Does this cryogenic chamber make me look fat?"));
29+
Assert.That(teenager.Hey("Does this cryogenic chamber make me look fat?"), Is.EqualTo("Sure."));
3030
}
3131

3232
[Test, Ignore]
33-
public void AskingANumericQuestion ()
33+
public void Asking_a_numeric_question ()
3434
{
35-
Assert.AreEqual("Sure.", teenager.Hey("You are, what, like 15?"));
35+
Assert.That(teenager.Hey("You are, what, like 15?"), Is.EqualTo("Sure."));
3636
}
3737

3838
[Test, Ignore]
39-
public void TalkingForcefully ()
39+
public void Talking_forcefully ()
4040
{
41-
Assert.AreEqual("Whatever.", teenager.Hey("Let's go make out behind the gym!"));
41+
Assert.That(teenager.Hey("Let's go make out behind the gym!"), Is.EqualTo("Whatever."));
4242
}
4343

4444
[Test, Ignore]
45-
public void UsingAcronymsInRegularSearch ()
45+
public void Using_acronyms_in_regular_search ()
4646
{
47-
Assert.AreEqual("Whatever.", teenager.Hey("It's OK if you don't want to go to the DMV."));
47+
Assert.That(teenager.Hey("It's OK if you don't want to go to the DMV."), Is.EqualTo("Whatever."));
4848
}
4949

5050
[Test, Ignore]
51-
public void ForcefulQuestions ()
51+
public void Forceful_questions ()
5252
{
53-
Assert.AreEqual("Woah, chill out!", teenager.Hey("WHAT THE HELL WERE YOU THINKING?"));
53+
Assert.That(teenager.Hey("WHAT THE HELL WERE YOU THINKING?"), Is.EqualTo("Woah, chill out!"));
5454
}
5555

5656
[Test, Ignore]
57-
public void ShoutingNumbers ()
57+
public void Shouting_numbers ()
5858
{
59-
Assert.AreEqual("Woah, chill out!", teenager.Hey("1, 2, 3 GO!"));
59+
Assert.That(teenager.Hey("1, 2, 3 GO!"), Is.EqualTo("Woah, chill out!"));
6060
}
6161

6262
[Test, Ignore]
63-
public void OnlyNumbers ()
63+
public void Only_numbers ()
6464
{
65-
Assert.AreEqual("Whatever.", teenager.Hey("1, 2, 3"));
65+
Assert.That(teenager.Hey("1, 2, 3"), Is.EqualTo("Whatever."));
6666
}
6767

6868
[Test, Ignore]
69-
public void QuestionWithOnlyNumbers ()
69+
public void Question_with_only_numbers ()
7070
{
71-
Assert.AreEqual("Sure.", teenager.Hey("4?"));
71+
Assert.That(teenager.Hey("4?"), Is.EqualTo("Sure."));
7272
}
7373

7474
[Test, Ignore]
75-
public void ShoutingWithSpecialCharacters ()
75+
public void Shouting_with_special_characters ()
7676
{
77-
Assert.AreEqual("Woah, chill out!", teenager.Hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"));
77+
Assert.That(teenager.Hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"), Is.EqualTo("Woah, chill out!"));
7878
}
7979

8080
[Test, Ignore]
81-
public void ShoutingWithNoExclamationMark ()
81+
public void Shouting_with_no_exclamation_mark ()
8282
{
83-
Assert.AreEqual("Woah, chill out!", teenager.Hey("I HATE YOU"));
83+
Assert.That(teenager.Hey("I HATE YOU"), Is.EqualTo("Woah, chill out!"));
8484
}
8585

8686
[Test, Ignore]
87-
public void StatementContainingQuestionMark ()
87+
public void Statement_containing_question_mark ()
8888
{
89-
Assert.AreEqual("Whatever.", teenager.Hey("Ending with ? means a question."));
89+
Assert.That(teenager.Hey("Ending with ? means a question."), Is.EqualTo("Whatever."));
9090
}
9191

9292
[Test, Ignore]
93-
public void PrattlingOn ()
93+
public void Prattling_on ()
9494
{
95-
Assert.AreEqual("Sure.", teenager.Hey("Wait! Hang on. Are you going to be OK?"));
95+
Assert.That(teenager.Hey("Wait! Hang on. Are you going to be OK?"), Is.EqualTo("Sure."));
9696
}
9797

9898
[Test, Ignore]
9999
public void Silence ()
100100
{
101-
Assert.AreEqual("Fine. Be that way!", teenager.Hey(""));
101+
Assert.That(teenager.Hey(""), Is.EqualTo("Fine. Be that way!"));
102102
}
103103

104104
[Test, Ignore]
105-
public void ProlongedSilence ()
105+
public void Prolonged_silence ()
106106
{
107-
Assert.AreEqual("Fine. Be that way!", teenager.Hey(" "));
107+
Assert.That(teenager.Hey(" "), Is.EqualTo("Fine. Be that way!"));
108108
}
109109

110110
[Test, Ignore]
111-
public void MultipleLineQuestion ()
111+
public void Multiple_line_question ()
112112
{
113-
Assert.AreEqual("Whatever.", teenager.Hey("Does this cryogenic chamber make me look fat?\nno"));
113+
Assert.That(teenager.Hey("Does this cryogenic chamber make me look fat?\nno"), Is.EqualTo("Whatever."));
114114
}
115-
116115
}

etl/ETLTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
public class ETLTest
66
{
77
[Test]
8-
public void TransformsOneValue()
8+
public void Transforms_one_value()
99
{
1010
var old = new Dictionary<int, IList<string>> { { 1, new List<string> { "A" } } };
1111
var expected = new Dictionary<string, int> { { "a", 1 } };
12-
Assert.That(ETL.Transform(old), Is.EquivalentTo(expected));
12+
Assert.That(ETL.Transform(old), Is.EqualTo(expected));
1313
}
1414

1515
[Test, Ignore]
16-
public void TransformsMultipleValues()
16+
public void Transforms_multiple_values()
1717
{
1818
var old = new Dictionary<int, IList<string>> { { 1, new List<string> { "A", "E", "I", "O", "U" } } };
1919
var expected = new Dictionary<string, int> { { "a", 1 }, { "e", 1 }, { "i", 1 }, { "o", 1 }, { "u", 1 } };
20-
Assert.That(ETL.Transform(old), Is.EquivalentTo(expected));
20+
Assert.That(ETL.Transform(old), Is.EqualTo(expected));
2121
}
2222

2323
[Test, Ignore]
24-
public void TransformsMultipleKeys()
24+
public void Transforms_multiple_keys()
2525
{
2626
var old = new Dictionary<int, IList<string>> { { 1, new List<string> { "A", "E" } }, { 2, new List<string> { "D", "G" } } };
2727
var expected = new Dictionary<string, int> { { "a", 1 }, { "e", 1 }, { "d", 2 }, { "g", 2 } };
28-
Assert.That(ETL.Transform(old), Is.EquivalentTo(expected));
28+
Assert.That(ETL.Transform(old), Is.EqualTo(expected));
2929
}
3030

3131
[Test, Ignore]
32-
public void TransformsAFullDataset()
32+
public void Transforms_a_full_dataset()
3333
{
3434
var old = new Dictionary<int, IList<string>>
3535
{
@@ -47,6 +47,6 @@ public void TransformsAFullDataset()
4747
{ "j", 8 }, { "k", 5 }, { "l", 1 }, { "m", 3 }, { "n", 1 }, { "o", 1 }, { "p", 3 }, { "q", 10 }, { "r", 1 },
4848
{ "s", 1 }, { "t", 1 }, { "u", 1 }, { "v", 4 }, { "w", 4 }, { "x", 8 }, { "y", 4 }, { "z", 10 }
4949
};
50-
Assert.That(ETL.Transform(old), Is.EquivalentTo(expected));
50+
Assert.That(ETL.Transform(old), Is.EqualTo(expected));
5151
}
5252
}

grade-school/GradeSchoolTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ public void Setup()
1313
}
1414

1515
[Test]
16-
public void NewSchoolHasAnEmptyRoster()
16+
public void New_school_has_an_empty_roster()
1717
{
1818
Assert.That(school.Roster, Has.Count.EqualTo(0));
1919
}
2020

2121
[Test, Ignore]
22-
public void AddingAStudentAddsThemToTheRosterForTheGivenGrade()
22+
public void Adding_a_student_adds_them_to_the_roster_for_the_given_grade()
2323
{
2424
school.Add("Aimee", 2);
2525
var expected = new List<string> { "Aimee" };
2626
Assert.That(school.Roster[2], Is.EqualTo(expected));
2727
}
2828

2929
[Test, Ignore]
30-
public void AddingMoreStudentsToTheSameGradeAddsThemToTheRoster()
30+
public void Adding_more_students_to_the_same_grade_adds_them_to_the_roster()
3131
{
3232
school.Add("Blair", 2);
3333
school.Add("James", 2);
@@ -37,7 +37,7 @@ public void AddingMoreStudentsToTheSameGradeAddsThemToTheRoster()
3737
}
3838

3939
[Test, Ignore]
40-
public void AddingStudentsToDifferentGradesAddsThemToTheRoster()
40+
public void Adding_students_to_different_grades_adds_them_to_the_roster()
4141
{
4242
school.Add("Chelsea", 3);
4343
school.Add("Logan", 7);
@@ -46,7 +46,7 @@ public void AddingStudentsToDifferentGradesAddsThemToTheRoster()
4646
}
4747

4848
[Test, Ignore]
49-
public void GradeReturnsTheStudentsInThatGradeInAlphabeticalOrder()
49+
public void Grade_returns_the_students_in_that_grade_in_alphabetical_order()
5050
{
5151
school.Add("Franklin", 5);
5252
school.Add("Bradley", 5);
@@ -56,13 +56,13 @@ public void GradeReturnsTheStudentsInThatGradeInAlphabeticalOrder()
5656
}
5757

5858
[Test, Ignore]
59-
public void GradeReturnsAnEmptyListIfThereAreNoStudentsInThatGrade()
59+
public void Grade_returns_an_empty_list_if_there_are_no_students_in_that_grade()
6060
{
6161
Assert.That(school.Grade(1), Is.EqualTo(new List<string>()));
6262
}
6363

6464
[Test, Ignore]
65-
public void StudentNamesInEachGradeInRosterAreSorted()
65+
public void Student_names_in_each_grade_in_roster_are_sorted()
6666
{
6767
school.Add("Jennifer", 4);
6868
school.Add("Kareem", 6);

0 commit comments

Comments
 (0)