public void ShouldReturnLocalizationFromDictionary() { var dictionary = new LocalizationDictionary { {"sv-se","k","Key"} }; var t = new FallbackDictionaryLocalizer(dictionary, "sv-se"); Assert.Equal("Key", t.Localize("k")); }
public void ShouldReturnFallbackLocalizationIfFullLocaleNotFound() { var dictionary = new LocalizationDictionary { {"sv","k","Fallback"} }; var t = new FallbackDictionaryLocalizer(dictionary, "sv-se","sv"); Assert.Equal("Fallback", t.Localize("k")); }
public void ShouldReturnValueFromDefaultLocalizerIfNotFound() { var dictionary = new LocalizationDictionary(); var t = new FallbackDictionaryLocalizer(dictionary, "sv-se") { DefaultLocalizer = (k, p) => new LocalizedString(k, "default") }; Assert.Equal("default", t.Localize("k")); }
public void ShouldReturnEmptyLocalizedStringIfKeyIsNull() { var dictionary = new LocalizationDictionary(); var t = new FallbackDictionaryLocalizer(dictionary, "sv-se"); Assert.Null(t.Localize(null).Localization); }