diff --git a/src/NzbDrone.Common.Test/ExtensionTests/StringExtensionTests/FirstCharcacterToLowerFixture.cs b/src/NzbDrone.Common.Test/ExtensionTests/StringExtensionTests/FirstCharcacterToLowerFixture.cs new file mode 100644 index 000000000..e1314dcca --- /dev/null +++ b/src/NzbDrone.Common.Test/ExtensionTests/StringExtensionTests/FirstCharcacterToLowerFixture.cs @@ -0,0 +1,18 @@ +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Common.Extensions; + +namespace NzbDrone.Common.Test.ExtensionTests.StringExtensionTests +{ + [TestFixture] + public class FirstCharcacterToLowerFixture + { + [TestCase("Hello", "hello")] + [TestCase("CamelCase", "camelCase")] + [TestCase("A Full Sentence", "a Full Sentence")] + public void should_lower_case_first_character(string input, string expected) + { + input.FirstCharToLower().Should().Be(expected); + } + } +} diff --git a/src/NzbDrone.Common.Test/ExtensionTests/StringExtensionTests/FirstCharcacterToUpperFixture.cs b/src/NzbDrone.Common.Test/ExtensionTests/StringExtensionTests/FirstCharcacterToUpperFixture.cs new file mode 100644 index 000000000..bf8169b60 --- /dev/null +++ b/src/NzbDrone.Common.Test/ExtensionTests/StringExtensionTests/FirstCharcacterToUpperFixture.cs @@ -0,0 +1,18 @@ +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Common.Extensions; + +namespace NzbDrone.Common.Test.ExtensionTests.StringExtensionTests +{ + [TestFixture] + public class FirstCharcacterToUpperFixture + { + [TestCase("hello", "Hello")] + [TestCase("camelCase", "CamelCase")] + [TestCase("a full sentence", "A full sentence")] + public void should_capitalize_first_character(string input, string expected) + { + input.FirstCharToUpper().Should().Be(expected); + } + } +} diff --git a/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj b/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj index 98227148e..91addf565 100644 --- a/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj +++ b/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj @@ -70,6 +70,8 @@ + + diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index 1fe5b90f2..bbc9f4676 100644 --- a/src/NzbDrone.Common/Extensions/StringExtensions.cs +++ b/src/NzbDrone.Common/Extensions/StringExtensions.cs @@ -22,9 +22,14 @@ namespace NzbDrone.Common.Extensions return "[NULL]"; } + public static string FirstCharToLower(this string input) + { + return input.First().ToString().ToLower() + input.Substring(1); + } + public static string FirstCharToUpper(this string input) { - return input.First().ToString().ToUpper() + string.Join("", input.Skip(1)); + return input.First().ToString().ToUpper() + input.Substring(1); } public static string Inject(this string format, params object[] formattingArgs)