mirror of https://github.com/Squidex/squidex.git
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.
54 lines
1.7 KiB
54 lines
1.7 KiB
// ==========================================================================
|
|
// StringExtensionsTests.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using Xunit;
|
|
|
|
namespace Squidex.Infrastructure
|
|
{
|
|
public class StringExtensionsTests
|
|
{
|
|
[Theory]
|
|
[InlineData("my", "My")]
|
|
[InlineData("myProperty ", "MyProperty")]
|
|
[InlineData("my property", "MyProperty")]
|
|
[InlineData("my_property", "MyProperty")]
|
|
[InlineData("my-property", "MyProperty")]
|
|
public void Should_convert_to_pascal_case(string input, string output)
|
|
{
|
|
Assert.Equal(output, input.ToPascalCase());
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("My", "my")]
|
|
[InlineData("MyProperty ", "myProperty")]
|
|
[InlineData("My property", "myProperty")]
|
|
[InlineData("My_property", "myProperty")]
|
|
[InlineData("My-property", "myProperty")]
|
|
public void Should_convert_to_camel_case(string input, string output)
|
|
{
|
|
Assert.Equal(output, input.ToCamelCase());
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
public void Should_provide_fallback_if_invalid(string value)
|
|
{
|
|
Assert.Equal("fallback", value.WithFallback("fallback"));
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_provide_value()
|
|
{
|
|
const string value = "value";
|
|
|
|
Assert.Equal(value, value.WithFallback("fallback"));
|
|
}
|
|
}
|
|
}
|
|
|