Exemplo n.º 1
0
        public void CultureByCode_Given_Invariant_CultureCode_Returns_Default_Culture()
        {
            // Act
            var result = LocalizationUtils.CultureByCode(CultureInfo.InvariantCulture.Name);

            // Assert
            result.ShouldNotBeNull();
            result.Code.ShouldBe(LocalizationUtils.DefaultCultureCode);
        }
Exemplo n.º 2
0
        public void CultureByCode_Given_CultureCode_Exists_Returns_Culture()
        {
            // Arrange
            var expected = new CultureStub().Code;

            // Act
            var result = LocalizationUtils.CultureByCode(expected);

            // Assert
            result.ShouldNotBeNull();
            result.ShouldBeOfType <CultureStub>();
            result.Code.ShouldBe(expected);
        }
Exemplo n.º 3
0
 private string GetString(string name)
 => LocalizationUtils.CultureByCode(CultureInfo.CurrentCulture.Name)
 .CultureTranslations
 .FirstOrDefault(r => r.Key == name)?.Value;
Exemplo n.º 4
0
 public IEnumerable <LocalizedString> GetAllStrings(bool includeAncestorCultures)
 => LocalizationUtils.CultureByCode(CultureInfo.CurrentCulture.Name)
 .CultureTranslations
 .Select(r => new LocalizedString(r.Key, r.Value, true));
Exemplo n.º 5
0
 public void CultureByCode_Given_CultureCode_DoesNotExist_Returns_Null()
 {
     LocalizationUtils.CultureByCode("404").ShouldBeNull();
 }