public void HtmlLocalizer_HtmlWithInvalidResourcestring_ThrowsException(string format) { // Arrange var localizedString = new LocalizedString("Hello", format); var stringLocalizer = new Mock <IStringLocalizer>(); stringLocalizer.Setup(s => s["Hello"]).Returns(localizedString); var htmlLocalizer = new HtmlLocalizer(stringLocalizer.Object, new CommonTestEncoder()); // Act var exception = Assert.Throws <FormatException>(() => htmlLocalizer.Html("Hello", new object[] { })); // Assert Assert.NotNull(exception); Assert.Equal("Input string was not in a correct format.", exception.Message); }
public void HtmlLocalizer_HtmlWithArguments_ReturnsLocalizedHtml( string format, object[] arguments, string expectedText) { // Arrange var localizedString = new LocalizedString("Hello", format); var stringLocalizer = new Mock <IStringLocalizer>(); stringLocalizer.Setup(s => s["Hello"]).Returns(localizedString); var htmlLocalizer = new HtmlLocalizer(stringLocalizer.Object, new CommonTestEncoder()); // Act var localizedHtmlString = htmlLocalizer.Html("Hello", arguments); // Assert Assert.NotNull(localizedHtmlString); Assert.Equal(expectedText, localizedHtmlString.Value); }
public void HtmlLocalizer_HtmlWithArguments_ReturnsLocalizedHtml( string format, object[] arguments, string expectedText) { // Arrange var localizedString = new LocalizedString("Hello", format); var stringLocalizer = new Mock<IStringLocalizer>(); stringLocalizer.Setup(s => s["Hello"]).Returns(localizedString); var htmlLocalizer = new HtmlLocalizer(stringLocalizer.Object, new CommonTestEncoder()); // Act var localizedHtmlString = htmlLocalizer.Html("Hello", arguments); // Assert Assert.NotNull(localizedHtmlString); Assert.Equal(expectedText, localizedHtmlString.Value); }
public void HtmlLocalizer_HtmlWithInvalidResourcestring_ThrowsException(string format) { // Arrange var localizedString = new LocalizedString("Hello", format); var stringLocalizer = new Mock<IStringLocalizer>(); stringLocalizer.Setup(s => s["Hello"]).Returns(localizedString); var htmlLocalizer = new HtmlLocalizer(stringLocalizer.Object, new CommonTestEncoder()); // Act var exception = Assert.Throws<FormatException>(() => htmlLocalizer.Html("Hello", new object[] { })); // Assert Assert.NotNull(exception); Assert.Equal("Input string was not in a correct format.", exception.Message); }