public void ViewLocalizer_WithCulture_ReturnsLocalizedHtmlString() { // Arrange var stringLocalizer = new TestStringLocalizer(); var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var hostingEnvironment = new Mock <IHostingEnvironment>(); hostingEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), hostingEnvironment.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_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); }