public void ViewLocalizer_WithCulture_ReturnsLocalizedHtmlString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock <IApplicationEnvironment>(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); var view = new Mock <IView>(); view.Setup(v => v.Path).Returns("example"); var viewContext = new ViewContext(); viewContext.View = view.Object; viewLocalizer.Contextualize(viewContext); // Act var actualLocalizedString = viewLocalizer.WithCulture(new CultureInfo("fr"))["John"]; // Assert Assert.Equal("Bonjour John", actualLocalizedString.Value); }
public void ViewLocalizer_GetAllStringsIncludeParentCulture_ReturnsLocalizedString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock <IApplicationEnvironment>(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); var view = new Mock <IView>(); view.Setup(v => v.Path).Returns("example"); var viewContext = new ViewContext(); viewContext.View = view.Object; viewLocalizer.Contextualize(viewContext); // Act var allLocalizedStrings = viewLocalizer.GetAllStrings(includeParentCultures: true).ToList(); // Assert Assert.Equal(2, allLocalizedStrings.Count); Assert.Equal("World", allLocalizedStrings[0].Value); Assert.Equal("Bar", allLocalizedStrings[1].Value); }
public void ViewLocalizer_HtmlWithArguments_ReturnsLocalizedHtmlString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock <IApplicationEnvironment>(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); var view = new Mock <IView>(); view.Setup(v => v.Path).Returns("example"); var viewContext = new ViewContext(); viewContext.View = view.Object; viewLocalizer.Contextualize(viewContext); // Act var actualLocalizedString = viewLocalizer.GetHtml("John", "Doe"); // Assert Assert.Equal("Hello John Doe", actualLocalizedString.Value); }
public void HtmlLocalizer_WithCulture_ReturnsLocalizedHtmlString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); // Act var actualLocalizedHtmlString = htmlLocalizer.WithCulture(new CultureInfo("fr"))["John"]; // Assert Assert.Equal("Bonjour John", actualLocalizedHtmlString.Value); }
public void HtmlLocalizer_GetStringWithArguments_ReturnsLocalizedString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); // Act var actualLocalizedString = htmlLocalizer.GetString("John", "Doe"); // Assert Assert.Equal("Hello John Doe", actualLocalizedString.Value); }
public void HtmlLocalizer_Html_ReturnsLocalizedHtmlString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); // Act var actualLocalizedHtmlString = htmlLocalizer.GetHtml("John"); // Assert Assert.Equal("Hello John", actualLocalizedHtmlString.Value); }
public void HtmlLocalizer_GetAllStrings_ReturnsAllLocalizedStrings() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); // Act var allLocalizedStrings = htmlLocalizer.GetAllStrings(includeParentCultures: false).ToList(); //Assert Assert.Equal(1, allLocalizedStrings.Count); Assert.Equal("World", allLocalizedStrings.First().Value); }
public void ViewLocalizer_HtmlWithArguments_ReturnsLocalizedHtmlString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock<IApplicationEnvironment>(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); var view = new Mock<IView>(); view.Setup(v => v.Path).Returns("example"); var viewContext = new ViewContext(); viewContext.View = view.Object; viewLocalizer.Contextualize(viewContext); // Act var actualLocalizedString = viewLocalizer.GetHtml("John", "Doe"); // Assert Assert.Equal("Hello John Doe", actualLocalizedString.Value); }
public void ViewLocalizer_WithCulture_ReturnsLocalizedHtmlString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock<IApplicationEnvironment>(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); var view = new Mock<IView>(); view.Setup(v => v.Path).Returns("example"); var viewContext = new ViewContext(); viewContext.View = view.Object; viewLocalizer.Contextualize(viewContext); // Act var actualLocalizedString = viewLocalizer.WithCulture(new CultureInfo("fr"))["John"]; // Assert Assert.Equal("Bonjour John", actualLocalizedString.Value); }
public void ViewLocalizer_GetAllStringsIncludeParentCulture_ReturnsLocalizedString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock<IApplicationEnvironment>(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); var view = new Mock<IView>(); view.Setup(v => v.Path).Returns("example"); var viewContext = new ViewContext(); viewContext.View = view.Object; viewLocalizer.Contextualize(viewContext); // Act var allLocalizedStrings = viewLocalizer.GetAllStrings(includeParentCultures: true).ToList(); // Assert Assert.Equal(2, allLocalizedStrings.Count); Assert.Equal("World", allLocalizedStrings[0].Value); Assert.Equal("Bar", allLocalizedStrings[1].Value); }
public void HtmlLocalizer_GetAllStringsIncludeParentCulture_ReturnsAllLocalizedStrings() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); // Act var allLocalizedStrings = htmlLocalizer.GetAllStrings().ToList(); //Assert Assert.Equal(2, allLocalizedStrings.Count); Assert.Equal("World", allLocalizedStrings[0].Value); Assert.Equal("Bar", allLocalizedStrings[1].Value); }