mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Add Tests for FirstCharTo
This commit is contained in:
parent
4af18f7d4a
commit
f868e8b964
@ -0,0 +1,36 @@
|
||||
using System.Globalization;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Common.Test.ExtensionTests.StringExtensionTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class FirstCharacterToLowerFixture
|
||||
{
|
||||
[TestCase("Hello", "hello")]
|
||||
[TestCase("CamelCase", "camelCase")]
|
||||
[TestCase("A Full Sentence", "a Full Sentence")]
|
||||
[TestCase("", "")]
|
||||
[TestCase(null, "")]
|
||||
public void should_lower_case_first_character(string input, string expected)
|
||||
{
|
||||
input.FirstCharToLower().Should().Be(expected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_lower_case_first_character_regardless_of_culture()
|
||||
{
|
||||
var current = CultureInfo.CurrentCulture;
|
||||
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("tr-TR");
|
||||
try
|
||||
{
|
||||
"InfInite".FirstCharToLower().Should().Be("infInite");
|
||||
}
|
||||
finally
|
||||
{
|
||||
CultureInfo.CurrentCulture = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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")]
|
||||
[TestCase("", "")]
|
||||
[TestCase(null, "")]
|
||||
public void should_capitalize_first_character(string input, string expected)
|
||||
{
|
||||
input.FirstCharToUpper().Should().Be(expected);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Common.Test.ExtensionTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class UrlExtensionsFixture
|
||||
{
|
||||
[TestCase("http://my.local/url")]
|
||||
[TestCase("https://my.local/url")]
|
||||
public void should_report_as_valid_url(string url)
|
||||
{
|
||||
url.IsValidUrl().Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase("")]
|
||||
[TestCase(" http://my.local/url")]
|
||||
[TestCase("http://my.local/url ")]
|
||||
public void should_report_as_invalid_url(string url)
|
||||
{
|
||||
url.IsValidUrl().Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
21
src/NzbDrone.Common.Test/HashUtilFixture.cs
Normal file
21
src/NzbDrone.Common.Test/HashUtilFixture.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class HashUtilFixture
|
||||
{
|
||||
[Test]
|
||||
public void should_create_anon_id()
|
||||
{
|
||||
HashUtil.AnonymousToken().Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_create_the_same_id()
|
||||
{
|
||||
HashUtil.AnonymousToken().Should().Be(HashUtil.AnonymousToken());
|
||||
}
|
||||
}
|
||||
}
|
@ -89,6 +89,10 @@
|
||||
<Compile Include="ExtensionTests\IEnumerableExtensionTests\IntersectByFixture.cs" />
|
||||
<Compile Include="ExtensionTests\Int64ExtensionFixture.cs" />
|
||||
<Compile Include="ExtensionTests\IPAddressExtensionsFixture.cs" />
|
||||
<Compile Include="ExtensionTests\StringExtensionTests\FirstCharacterToLowerFixture.cs" />
|
||||
<Compile Include="ExtensionTests\StringExtensionTests\FirstCharcacterToUpperFixture.cs" />
|
||||
<Compile Include="ExtensionTests\UrlExtensionsFixture.cs" />
|
||||
<Compile Include="HashUtilFixture.cs" />
|
||||
<Compile Include="Http\HttpClientFixture.cs" />
|
||||
<Compile Include="Http\HttpHeaderFixture.cs" />
|
||||
<Compile Include="Http\HttpRequestBuilderFixture.cs" />
|
||||
|
@ -24,12 +24,22 @@ public static object NullSafe(this object target)
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user