mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-19 22:04:56 -04:00
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System;
|
|
using FluentAssertions;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
using NzbDrone.Core.Configuration;
|
|
using NzbDrone.Core.Localization;
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
namespace NzbDrone.Core.Test.Localization
|
|
{
|
|
[TestFixture]
|
|
public class LocalizationServiceFixture : CoreTest<LocalizationService>
|
|
{
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
Mocker.GetMock<IConfigService>().Setup(m => m.UILanguage).Returns("en");
|
|
|
|
Mocker.GetMock<IAppFolderInfo>().Setup(m => m.StartUpFolder).Returns(TestContext.CurrentContext.TestDirectory);
|
|
}
|
|
|
|
[Test]
|
|
public void should_get_string_in_dictionary_if_lang_exists_and_string_exists()
|
|
{
|
|
var localizedString = Subject.GetLocalizedString("BackupNow");
|
|
|
|
localizedString.Should().Be("Backup Now");
|
|
}
|
|
|
|
[Test]
|
|
public void should_get_string_in_french()
|
|
{
|
|
Mocker.GetMock<IConfigService>().Setup(m => m.UILanguage).Returns("fr");
|
|
|
|
var localizedString = Subject.GetLocalizedString("BackupNow");
|
|
|
|
localizedString.Should().Be("Sauvegarder maintenant");
|
|
}
|
|
|
|
[Test]
|
|
public void should_get_string_in_default_dictionary_if_unknown_language_and_string_exists()
|
|
{
|
|
Mocker.GetMock<IConfigService>().Setup(m => m.UILanguage).Returns("");
|
|
var localizedString = Subject.GetLocalizedString("BackupNow");
|
|
|
|
localizedString.Should().Be("Backup Now");
|
|
}
|
|
|
|
[Test]
|
|
public void should_return_argument_if_string_doesnt_exists()
|
|
{
|
|
var localizedString = Subject.GetLocalizedString("BadString");
|
|
|
|
localizedString.Should().Be("BadString");
|
|
}
|
|
|
|
[Test]
|
|
public void should_return_argument_if_string_doesnt_exists_default_lang()
|
|
{
|
|
var localizedString = Subject.GetLocalizedString("BadString");
|
|
|
|
localizedString.Should().Be("BadString");
|
|
}
|
|
|
|
[Test]
|
|
public void should_throw_if_empty_string_passed()
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() => Subject.GetLocalizedString(""));
|
|
}
|
|
|
|
[Test]
|
|
public void should_throw_if_null_string_passed()
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() => Subject.GetLocalizedString(null));
|
|
}
|
|
}
|
|
}
|