Skip to content

Commit

Permalink
Add pig-latin exercise generator
Browse files Browse the repository at this point in the history
Refs #194, #195
  • Loading branch information
ErikSchierboom committed Mar 19, 2017
1 parent 5d446b2 commit a7d9aa8
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 27 deletions.
93 changes: 69 additions & 24 deletions exercises/pig-latin/PigLatinTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,122 @@

public class PigLatinTest
{
[Theory]
[InlineData("apple", "appleay")]
[InlineData("ear", "earay")]
[InlineData("igloo", "iglooay")]
[InlineData("object", "objectay")]
[InlineData("under", "underay")]
public void Ay_is_added_to_words_that_start_with_vowels(string word, string expected)
[Fact]
public void Word_beginning_with_a()
{
Assert.Equal(expected, PigLatin.Translate(word));
Assert.Equal("appleay", PigLatin.Translate("apple"));
}

[Theory(Skip = "Remove to run test")]
[InlineData("pig", "igpay")]
[InlineData("koala", "oalakay")]
[InlineData("yellow", "ellowyay")]
[InlineData("xenon", "enonxay")]
public void First_letter_and_ay_are_moved_to_the_end_of_words_that_start_with_consonants(string word, string expected)
[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_e()
{
Assert.Equal("earay", PigLatin.Translate("ear"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_i()
{
Assert.Equal("iglooay", PigLatin.Translate("igloo"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_o()
{
Assert.Equal("objectay", PigLatin.Translate("object"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_u()
{
Assert.Equal("underay", PigLatin.Translate("under"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_a_vowel_and_followed_by_a_qu()
{
Assert.Equal("equalay", PigLatin.Translate("equal"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_p()
{
Assert.Equal("igpay", PigLatin.Translate("pig"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_k()
{
Assert.Equal("oalakay", PigLatin.Translate("koala"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_y()
{
Assert.Equal("ellowyay", PigLatin.Translate("yellow"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_x()
{
Assert.Equal("enonxay", PigLatin.Translate("xenon"));
}

[Fact(Skip = "Remove to run test")]
public void Word_beginning_with_q_without_a_following_u()
{
Assert.Equal(expected, PigLatin.Translate(word));
Assert.Equal("atqay", PigLatin.Translate("qat"));
}

[Fact(Skip = "Remove to run test")]
public void Ch_is_treated_like_a_single_consonant()
public void Word_beginning_with_ch()
{
Assert.Equal("airchay", PigLatin.Translate("chair"));
}

[Fact(Skip = "Remove to run test")]
public void Qu_is_treated_like_a_single_consonant()
public void Word_beginning_with_qu()
{
Assert.Equal("eenquay", PigLatin.Translate("queen"));
}

[Fact(Skip = "Remove to run test")]
public void Qu_and_a_single_preceding_consonant_are_treated_like_a_single_consonant()
public void Word_beginning_with_qu_and_a_preceding_consonant()
{
Assert.Equal("aresquay", PigLatin.Translate("square"));
}

[Fact(Skip = "Remove to run test")]
public void Th_is_treated_like_a_single_consonant()
public void Word_beginning_with_th()
{
Assert.Equal("erapythay", PigLatin.Translate("therapy"));
}

[Fact(Skip = "Remove to run test")]
public void Thr_is_treated_like_a_single_consonant()
public void Word_beginning_with_thr()
{
Assert.Equal("ushthray", PigLatin.Translate("thrush"));
}

[Fact(Skip = "Remove to run test")]
public void Sch_is_treated_like_a_single_consonant()
public void Word_beginning_with_sch()
{
Assert.Equal("oolschay", PigLatin.Translate("school"));
}

[Fact(Skip = "Remove to run test")]
public void Yt_is_treated_like_a_single_vowel()
public void Word_beginning_with_yt()
{
Assert.Equal("yttriaay", PigLatin.Translate("yttria"));
}

[Fact(Skip = "Remove to run test")]
public void Xr_is_treated_like_a_single_vowel()
public void Word_beginning_with_xr()
{
Assert.Equal("xrayay", PigLatin.Translate("xray"));
}

[Fact(Skip = "Remove to run test")]
public void Phrases_are_translated()
public void A_whole_phrase()
{
Assert.Equal("ickquay astfay unray", PigLatin.Translate("quick fast run"));
}
Expand Down
12 changes: 12 additions & 0 deletions generators/Exercises/PigLatinExercise.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Generators.Exercises
{
public class PigLatinExercise : Exercise
{
public PigLatinExercise() : base("pig-latin")
{
}

protected override TestMethod CreateTestMethod(TestMethodData testMethodData)
=> CreateEqualityTestMethod(testMethodData);
}
}
4 changes: 1 addition & 3 deletions generators/TestedClassNameTransformer.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Text.RegularExpressions;
using Humanizer;

namespace Generators
{
public class TestedClassNameTransformer : IStringTransformer
{
public string Transform(string input)
=> Regex.Replace(input, @"[^\w]+", "", RegexOptions.Compiled).Underscore().Transform(Humanizer.To.TitleCase);
public string Transform(string input) => input.Dehumanize();
}
}

0 comments on commit a7d9aa8

Please sign in to comment.