2021-06-05 11:32:22 +00:00
|
|
|
using System;
|
|
|
|
using FsCheck;
|
|
|
|
using FsCheck.Xunit;
|
2020-04-19 16:27:07 +00:00
|
|
|
using MediaBrowser.Model.Extensions;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.Model.Tests.Extensions
|
|
|
|
{
|
|
|
|
public class StringHelperTests
|
|
|
|
{
|
|
|
|
[Theory]
|
|
|
|
[InlineData("", "")]
|
|
|
|
[InlineData("banana", "Banana")]
|
|
|
|
[InlineData("Banana", "Banana")]
|
|
|
|
[InlineData("ä", "Ä")]
|
2021-06-05 11:32:22 +00:00
|
|
|
[InlineData("\027", "\027")]
|
2020-04-21 08:21:20 +00:00
|
|
|
public void StringHelper_ValidArgs_Success(string input, string expectedResult)
|
2020-04-19 16:27:07 +00:00
|
|
|
{
|
2020-04-21 08:21:20 +00:00
|
|
|
Assert.Equal(expectedResult, StringHelper.FirstToUpper(input));
|
2020-04-19 16:27:07 +00:00
|
|
|
}
|
2021-06-05 11:32:22 +00:00
|
|
|
|
|
|
|
[Property]
|
|
|
|
public Property FirstToUpper_RandomArg_Correct(NonEmptyString input)
|
|
|
|
{
|
|
|
|
var result = StringHelper.FirstToUpper(input.Item);
|
|
|
|
|
|
|
|
// We check IsLower instead of IsUpper because both return false for non-letters
|
|
|
|
return (!char.IsLower(result[0])).Label("First char is uppercase")
|
|
|
|
.And(input.Item.Length == 1 || result[1..].Equals(input.Item[1..], StringComparison.Ordinal)).Label("Remaining chars are unmodified");
|
|
|
|
}
|
2020-04-19 16:27:07 +00:00
|
|
|
}
|
|
|
|
}
|