Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Hyphenate method which calls Dasherize #53

Merged
merged 2 commits into from Jan 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}