mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 13:10:13 -07:00
Clean up FirstCharacterToLower extension + tests
This commit is contained in:
parent
91082b2903
commit
2ce0fadb65
4 changed files with 19 additions and 5 deletions
|
@ -5,11 +5,13 @@ using NzbDrone.Common.Extensions;
|
||||||
namespace NzbDrone.Common.Test.ExtensionTests.StringExtensionTests
|
namespace NzbDrone.Common.Test.ExtensionTests.StringExtensionTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class FirstCharcacterToLowerFixture
|
public class FirstCharacterToLowerFixture
|
||||||
{
|
{
|
||||||
[TestCase("Hello", "hello")]
|
[TestCase("Hello", "hello")]
|
||||||
[TestCase("CamelCase", "camelCase")]
|
[TestCase("CamelCase", "camelCase")]
|
||||||
[TestCase("A Full Sentence", "a Full Sentence")]
|
[TestCase("A Full Sentence", "a Full Sentence")]
|
||||||
|
[TestCase("", "")]
|
||||||
|
[TestCase(null, "")]
|
||||||
public void should_lower_case_first_character(string input, string expected)
|
public void should_lower_case_first_character(string input, string expected)
|
||||||
{
|
{
|
||||||
input.FirstCharToLower().Should().Be(expected);
|
input.FirstCharToLower().Should().Be(expected);
|
|
@ -10,6 +10,8 @@ namespace NzbDrone.Common.Test.ExtensionTests.StringExtensionTests
|
||||||
[TestCase("hello", "Hello")]
|
[TestCase("hello", "Hello")]
|
||||||
[TestCase("camelCase", "CamelCase")]
|
[TestCase("camelCase", "CamelCase")]
|
||||||
[TestCase("a full sentence", "A full sentence")]
|
[TestCase("a full sentence", "A full sentence")]
|
||||||
|
[TestCase("", "")]
|
||||||
|
[TestCase(null, "")]
|
||||||
public void should_capitalize_first_character(string input, string expected)
|
public void should_capitalize_first_character(string input, string expected)
|
||||||
{
|
{
|
||||||
input.FirstCharToUpper().Should().Be(expected);
|
input.FirstCharToUpper().Should().Be(expected);
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
<Compile Include="ExtensionTests\IEnumerableExtensionTests\ExceptByFixture.cs" />
|
<Compile Include="ExtensionTests\IEnumerableExtensionTests\ExceptByFixture.cs" />
|
||||||
<Compile Include="ExtensionTests\IEnumerableExtensionTests\IntersectByFixture.cs" />
|
<Compile Include="ExtensionTests\IEnumerableExtensionTests\IntersectByFixture.cs" />
|
||||||
<Compile Include="ExtensionTests\Int64ExtensionFixture.cs" />
|
<Compile Include="ExtensionTests\Int64ExtensionFixture.cs" />
|
||||||
<Compile Include="ExtensionTests\StringExtensionTests\FirstCharcacterToLowerFixture.cs" />
|
<Compile Include="ExtensionTests\StringExtensionTests\FirstCharacterToLowerFixture.cs" />
|
||||||
<Compile Include="ExtensionTests\StringExtensionTests\FirstCharcacterToUpperFixture.cs" />
|
<Compile Include="ExtensionTests\StringExtensionTests\FirstCharcacterToUpperFixture.cs" />
|
||||||
<Compile Include="ExtensionTests\UrlExtensionsFixture.cs" />
|
<Compile Include="ExtensionTests\UrlExtensionsFixture.cs" />
|
||||||
<Compile Include="ExtensionTests\FuzzyContainsFixture.cs" />
|
<Compile Include="ExtensionTests\FuzzyContainsFixture.cs" />
|
||||||
|
@ -175,4 +175,4 @@
|
||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -24,12 +24,22 @@ namespace NzbDrone.Common.Extensions
|
||||||
|
|
||||||
public static string FirstCharToLower(this string input)
|
public static string FirstCharToLower(this string input)
|
||||||
{
|
{
|
||||||
return input.First().ToString().ToLower() + input.Substring(1);
|
if (string.IsNullOrEmpty(input))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return char.ToLowerInvariant(input.First()) + input.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FirstCharToUpper(this string input)
|
public static string FirstCharToUpper(this string input)
|
||||||
{
|
{
|
||||||
return input.First().ToString().ToUpper() + input.Substring(1);
|
if (string.IsNullOrEmpty(input))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return char.ToUpperInvariant(input.First()) + input.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Inject(this string format, params object[] formattingArgs)
|
public static string Inject(this string format, params object[] formattingArgs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue