You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/tests/Jellyfin.Model.Tests/Extensions/StringHelperTests.cs

33 lines
1.1 KiB

using System;
using FsCheck;
using FsCheck.Xunit;
5 years ago
using MediaBrowser.Model.Extensions;
using Xunit;
namespace Jellyfin.Model.Tests.Extensions
{
public class StringHelperTests
{
[Theory]
[InlineData("", "")]
[InlineData("banana", "Banana")]
[InlineData("Banana", "Banana")]
[InlineData("ä", "Ä")]
[InlineData("\027", "\027")]
5 years ago
public void StringHelper_ValidArgs_Success(string input, string expectedResult)
5 years ago
{
5 years ago
Assert.Equal(expectedResult, StringHelper.FirstToUpper(input));
5 years ago
}
[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");
}
5 years ago
}
}