public void Translate_ForEmptyKey_ResturnsMaskedNull(string key, string expected) { // Arrange var cultureInfo = Plugin.Multilingual.CrossMultilingual.Current; cultureInfo.CurrentCultureInfo = new CultureInfo("en"); var serviceProvider = Mock.Of <IServiceProvider>(); var sut = new TranslationExtension { TranslationKey = key }; // Act var result = sut.ProvideValue(serviceProvider); var result2 = ((IMarkupExtension)sut).ProvideValue(serviceProvider); // Assert result.Should().Be(expected); result2.Should().Be(expected); }
public void Translate_ForExistingKeyInCulture_ResturnsTranslation(string culture, string expected) { // Arrange const string translationKey = "Value_1"; var cultureInfo = Plugin.Multilingual.CrossMultilingual.Current; cultureInfo.CurrentCultureInfo = new CultureInfo(culture); var serviceProvider = Mock.Of <IServiceProvider>(); var sut = new TranslationExtension { TranslationKey = translationKey }; // Act var result = sut.ProvideValue(serviceProvider); var result2 = ((IMarkupExtension)sut).ProvideValue(serviceProvider); // Assert result.Should().Be(expected); result2.Should().Be(expected); }
public void Translate_ForNotExistingKey_ResturnsMaskedTranslationKey() { // Arrange const string translationKey = "NO_KEY"; const string expected = "[_NO_KEY_]"; var cultureInfo = Plugin.Multilingual.CrossMultilingual.Current; cultureInfo.CurrentCultureInfo = new CultureInfo("en"); var serviceProvider = Mock.Of <IServiceProvider>(); var sut = new TranslationExtension { TranslationKey = translationKey }; // Act var result = sut.ProvideValue(serviceProvider); var result2 = ((IMarkupExtension)sut).ProvideValue(serviceProvider); // Assert result.Should().Be(expected); result2.Should().Be(expected); }