Headless CMS and Content Managment Hub
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.
 
 
 
 
 

55 lines
1.5 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.Infrastructure.Translations;
using Squidex.Shared;
using Xunit;
namespace Squidex.Web.Services
{
public class StringLocalizerTests
{
private readonly StringLocalizer sut;
public StringLocalizerTests()
{
var translations = new ResourcesLocalizer(Texts.ResourceManager);
sut = new StringLocalizer(translations);
}
[Fact]
public void Should_provide_translation()
{
var key = "annotations_Required";
var name = sut[key];
Assert.Equal("The field '{0}' is required.", name);
}
[Fact]
public void Should_format_translation()
{
var key = "annotations_Required";
var name = sut[key, "MyField"];
Assert.Equal("The field 'MyField' is required.", name);
}
[Fact]
public void Should_translate_property_name()
{
var key = "annotations_Required";
var name = sut[key, "ClientId"];
Assert.Equal("The field 'Client ID' is required.", name);
}
}
}