Skip to content

Commit

Permalink
Merge pull request #53 from CodeFromJordan/master
Browse files Browse the repository at this point in the history
Added a Hyphenate method which calls Dasherize
  • Loading branch information
MehdiK committed Jan 6, 2014
2 parents ffc27ea + 5b81d32 commit 058f2a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Humanizer.Tests/InflectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ public void Dasherize(string input, string expectedOutput)
Assert.Equal(input.Dasherize(), expectedOutput);
}

[InlineData("some_title", "some-title")]
[InlineData("some-title", "some-title")]
[InlineData("some_title_goes_here", "some-title-goes-here")]
[InlineData("some_title and_another", "some-title and-another")]
[Theory]
public void Hyphenate(string input, string expectedOutput)
{
Assert.Equal(input.Hyphenate(), expectedOutput);
}

[Theory]
[InlineData("customer", "Customer")]
[InlineData("CUSTOMER", "CUSTOMER")]
Expand Down
10 changes: 10 additions & 0 deletions src/Humanizer/InflectorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,15 @@ public static string Dasherize(this string underscoredWord)
{
return underscoredWord.Replace('_', '-');
}

/// <summary>
/// Replaces underscores with hyphens in the string
/// </summary>
/// <param name="underscoredWord"></param>
/// <returns></returns>
public static string Hyphenate(this string underscoredWord)
{
return Dasherize(underscoredWord);
}
}
}

0 comments on commit 058f2a0

Please sign in to comment.