diff --git a/samples/LocalizationSample.Web/Resources/LocalizationSample.Web.Controllers.HomeController.fr.resx b/samples/LocalizationSample.Web/Resources/Controllers.HomeController.fr.resx
similarity index 100%
rename from samples/LocalizationSample.Web/Resources/LocalizationSample.Web.Controllers.HomeController.fr.resx
rename to samples/LocalizationSample.Web/Resources/Controllers.HomeController.fr.resx
diff --git a/samples/LocalizationSample.Web/Resources/LocalizationSample.Web.Models.Product.fr.resx b/samples/LocalizationSample.Web/Resources/Models.Product.fr.resx
similarity index 100%
rename from samples/LocalizationSample.Web/Resources/LocalizationSample.Web.Models.Product.fr.resx
rename to samples/LocalizationSample.Web/Resources/Models.Product.fr.resx
diff --git a/samples/LocalizationSample.Web/Resources/LocalizationSample.Web.Models.User.fr.resx b/samples/LocalizationSample.Web/Resources/Models.User.fr.resx
similarity index 100%
rename from samples/LocalizationSample.Web/Resources/LocalizationSample.Web.Models.User.fr.resx
rename to samples/LocalizationSample.Web/Resources/Models.User.fr.resx
diff --git a/samples/LocalizationSample.Web/Views/Home/Locpage.cshtml b/samples/LocalizationSample.Web/Views/Home/Locpage.cshtml
index de2a3a134d..90dddc4579 100644
--- a/samples/LocalizationSample.Web/Views/Home/Locpage.cshtml
+++ b/samples/LocalizationSample.Web/Views/Home/Locpage.cshtml
@@ -4,4 +4,4 @@
}
@LocString["Hello there!!"]
@ViewBag.Message
-@LocString.Html("Hi", "John", @date , @date.DayOfWeek)
+@LocString.GetHtml("Hi", "John", @date , @date.DayOfWeek)
diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs
index ceaa04de02..1d0c70d4a3 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs
@@ -9,12 +9,12 @@ using Microsoft.Extensions.Localization;
namespace Microsoft.AspNet.Mvc.Localization
{
///
- /// An that uses the to provide localized HTML content.
- /// This service just encodes the arguments but not the resource string.
+ /// An that uses the provided to do HTML-aware
+ /// localization of content.
///
public class HtmlLocalizer : IHtmlLocalizer
{
- private IStringLocalizer _localizer;
+ private readonly IStringLocalizer _localizer;
///
/// Creates a new .
@@ -31,38 +31,60 @@ namespace Microsoft.AspNet.Mvc.Localization
}
///
- public virtual LocalizedString this[string key]
+ public virtual LocalizedHtmlString this[string name]
{
get
{
- if (key == null)
+ if (name == null)
{
- throw new ArgumentNullException(nameof(key));
+ throw new ArgumentNullException(nameof(name));
}
- return _localizer[key];
+ return ToHtmlString(_localizer[name]);
}
}
///
- public virtual LocalizedString this[string key, params object[] arguments]
+ public virtual LocalizedHtmlString this[string name, params object[] arguments]
{
get
{
- if (key == null)
+ if (name == null)
{
- throw new ArgumentNullException(nameof(key));
+ throw new ArgumentNullException(nameof(name));
}
- return _localizer[key, arguments];
+ return ToHtmlString(_localizer[name], arguments);
}
}
- ///
- /// Creates a new for a specific .
- ///
- /// The to use.
- /// A culture-specific .
+ ///
+ public virtual LocalizedString GetString(string name)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ return _localizer[name];
+ }
+
+ ///
+ public virtual LocalizedString GetString(string name, params object[] arguments)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ return _localizer[name, arguments];
+ }
+
+ ///
+ public virtual IEnumerable GetAllStrings(bool includeParentCultures) =>
+ _localizer.GetAllStrings(includeParentCultures);
+
+ ///
public virtual IHtmlLocalizer WithCulture(CultureInfo culture)
{
if (culture == null)
@@ -73,69 +95,6 @@ namespace Microsoft.AspNet.Mvc.Localization
return new HtmlLocalizer(_localizer.WithCulture(culture));
}
- ///
- /// Creates a new for a specific .
- ///
- /// The to use.
- /// A culture-specific .
- IStringLocalizer IStringLocalizer.WithCulture(CultureInfo culture)
- {
- if (culture == null)
- {
- throw new ArgumentNullException(nameof(culture));
- }
-
- return new HtmlLocalizer(_localizer.WithCulture(culture));
- }
-
- ///
- public virtual LocalizedString GetString(string key)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return _localizer.GetString(key);
- }
-
- ///
- public virtual LocalizedString GetString(string key, params object[] arguments)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return _localizer.GetString(key, arguments);
- }
-
- ///
- public virtual IEnumerable GetAllStrings(bool includeAncestorCultures) =>
- _localizer.GetAllStrings(includeAncestorCultures);
-
- ///
- public virtual LocalizedHtmlString Html(string key)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return ToHtmlString(_localizer.GetString(key));
- }
-
- ///
- public virtual LocalizedHtmlString Html(string key, params object[] arguments)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return ToHtmlString(_localizer.GetString(key), arguments);
- }
-
///
/// Creates a new for a .
///
diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerExtensions.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerExtensions.cs
new file mode 100644
index 0000000000..21e96a6777
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerExtensions.cs
@@ -0,0 +1,71 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using Microsoft.Extensions.Localization;
+
+namespace Microsoft.AspNet.Mvc.Localization
+{
+ ///
+ /// Extension methods for .
+ ///
+ public static class HtmlLocalizerExtensions
+ {
+ ///
+ /// Gets the resource for a specific name.
+ ///
+ /// The key to use.
+ /// The resource.
+ public static LocalizedHtmlString GetHtml(this IHtmlLocalizer htmlLocalizer, string name)
+ {
+ if (htmlLocalizer == null)
+ {
+ throw new ArgumentNullException(nameof(htmlLocalizer));
+ }
+
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ return htmlLocalizer[name];
+ }
+
+ ///
+ /// Gets the resource for a specific name.
+ ///
+ /// The key to use.
+ /// The values to format the string with.
+ /// The resource.
+ public static LocalizedHtmlString GetHtml(this IHtmlLocalizer htmlLocalizer, string name, params object[] arguments)
+ {
+ if (htmlLocalizer == null)
+ {
+ throw new ArgumentNullException(nameof(htmlLocalizer));
+ }
+
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ return htmlLocalizer[name, arguments];
+ }
+
+ ///
+ /// Gets all string resources including those for parent cultures.
+ ///
+ /// The .
+ /// The string resources.
+ public static IEnumerable GetAllStrings(this IHtmlLocalizer htmlLocalizer)
+ {
+ if (htmlLocalizer == null)
+ {
+ throw new ArgumentNullException(nameof(htmlLocalizer));
+ }
+
+ return htmlLocalizer.GetAllStrings(includeParentCultures: true);
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs
index 8ad004bb67..0471fe5145 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs
@@ -7,14 +7,15 @@ using Microsoft.Extensions.Localization;
namespace Microsoft.AspNet.Mvc.Localization
{
///
- /// An that creates instances of .
+ /// An that creates instances of using the
+ /// registered .
///
public class HtmlLocalizerFactory : IHtmlLocalizerFactory
{
private readonly IStringLocalizerFactory _factory;
///
- /// Creates a new .
+ /// Creates a new .
///
/// The .
public HtmlLocalizerFactory(IStringLocalizerFactory localizerFactory)
@@ -28,10 +29,9 @@ namespace Microsoft.AspNet.Mvc.Localization
}
///
- /// Creates an using the and
- /// of the specified .
+ /// Creates an using the specified .
///
- /// The .
+ /// The to load resources for.
/// The .
public virtual IHtmlLocalizer Create(Type resourceSource)
{
@@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.Localization
}
///
- /// Creates an .
+ /// Creates an using the specified base name and location.
///
/// The base name of the resource to load strings from.
/// The location to load resources from.
diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs
index 4247dd8121..ccc6f0eb98 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerOfT.cs
@@ -9,7 +9,8 @@ using Microsoft.Extensions.Localization;
namespace Microsoft.AspNet.Mvc.Localization
{
///
- /// This is an implementation that provides localized HTML content.
+ /// An implementation that provides localized HTML content for the specified type
+ /// .
///
/// The to scope the resource names.
public class HtmlLocalizer : IHtmlLocalizer
@@ -17,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.Localization
private readonly IHtmlLocalizer _localizer;
///
- /// Creates a new .
+ /// Creates a new .
///
/// The .
public HtmlLocalizer(IHtmlLocalizerFactory factory)
@@ -26,33 +27,59 @@ namespace Microsoft.AspNet.Mvc.Localization
}
///
- public virtual LocalizedString this[string key]
+ public virtual LocalizedHtmlString this[string name]
{
get
{
- if (key == null)
+ if (name == null)
{
- throw new ArgumentNullException(nameof(key));
+ throw new ArgumentNullException(nameof(name));
}
- return _localizer[key];
+ return _localizer[name];
}
}
///
- public virtual LocalizedString this[string key, params object[] arguments]
+ public virtual LocalizedHtmlString this[string name, params object[] arguments]
{
get
{
- if (key == null)
+ if (name == null)
{
- throw new ArgumentNullException(nameof(key));
+ throw new ArgumentNullException(nameof(name));
}
- return _localizer[key, arguments];
+ return _localizer[name, arguments];
}
}
+ ///
+ public virtual LocalizedString GetString(string name)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ return _localizer.GetString(name);
+ }
+
+ ///
+ public virtual LocalizedString GetString(string name, params object[] arguments)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
+ return _localizer.GetString(name, arguments);
+ }
+
+ ///
+ public virtual IEnumerable GetAllStrings(bool includeParentCultures) =>
+ _localizer.GetAllStrings(includeParentCultures);
+
///
public virtual IHtmlLocalizer WithCulture(CultureInfo culture)
{
@@ -63,64 +90,5 @@ namespace Microsoft.AspNet.Mvc.Localization
return _localizer.WithCulture(culture);
}
-
- ///
- IStringLocalizer IStringLocalizer.WithCulture(CultureInfo culture)
- {
- if (culture == null)
- {
- throw new ArgumentNullException(nameof(culture));
- }
-
- return _localizer.WithCulture(culture);
- }
-
- ///
- public virtual LocalizedString GetString(string key)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return _localizer.GetString(key);
- }
-
- ///
- public virtual LocalizedString GetString(string key, params object[] arguments)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return _localizer.GetString(key, arguments);
- }
-
- ///
- public virtual LocalizedHtmlString Html(string key)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return _localizer.Html(key);
- }
-
- ///
- public virtual LocalizedHtmlString Html(string key, params object[] arguments)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- return _localizer.Html(key, arguments);
- }
-
- ///
- public virtual IEnumerable GetAllStrings(bool includeAncestorCultures) =>
- _localizer.GetAllStrings(includeAncestorCultures);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs b/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs
index b2c7436e49..45d9a7a0ca 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/IHtmlLocalizer.cs
@@ -1,37 +1,65 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System.Collections.Generic;
using System.Globalization;
using Microsoft.Extensions.Localization;
namespace Microsoft.AspNet.Mvc.Localization
{
///
- /// This service does not HTML encode the resource string. It HTML encodes all arguments that are formatted in
- /// the resource string.
+ /// Represents a type that that does HTML-aware localization of strings, by HTML encoding arguments that are
+ /// formatted in the resource string.
///
- public interface IHtmlLocalizer : IStringLocalizer
+ public interface IHtmlLocalizer
{
///
- /// Creates a new for a specific .
+ /// Gets the string resource with the given name.
+ ///
+ /// The name of the string resource.
+ /// The string resource as a .
+ LocalizedHtmlString this[string name] { get; }
+
+ ///
+ /// Gets the string resource with the given name and formatted with the supplied arguments. The arguments will
+ /// be HTML encoded.
+ ///
+ /// The name of the string resource.
+ /// The values to format the string with.
+ /// The formatted string resource as a .
+ LocalizedHtmlString this[string name, params object[] arguments] { get; }
+
+ ///
+ /// Gets the string resource with the given name.
+ ///
+ /// The .
+ /// The name of the string resource.
+ /// The string resource as a .
+ LocalizedString GetString(string name);
+
+ ///
+ /// Gets the string resource with the given name and formatted with the supplied arguments.
+ ///
+ /// The .
+ /// The name of the string resource.
+ /// The values to format the string with.
+ /// The formatted string resource as a .
+ LocalizedString GetString(string name, params object[] arguments);
+
+ ///
+ /// Gets all string resources.
+ ///
+ ///
+ /// A indicating whether to include strings from parent cultures.
+ ///
+ /// The strings.
+ IEnumerable GetAllStrings(bool includeParentCultures);
+
+ ///
+ /// Creates a new for a specific .
///
/// The to use.
/// A culture-specific .
- new IHtmlLocalizer WithCulture(CultureInfo culture);
-
- ///
- /// Gets the resource for a specific key.
- ///
- /// The key to use.
- /// The resource.
- LocalizedHtmlString Html(string key);
-
- ///
- /// Gets the resource for a specific key.
- ///
- /// The key to use.
- /// The values to format the string with.
- /// The resource.
- LocalizedHtmlString Html(string key, params object[] arguments);
+ IHtmlLocalizer WithCulture(CultureInfo culture);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Localization/LocalizedHtmlString.cs b/src/Microsoft.AspNet.Mvc.Localization/LocalizedHtmlString.cs
index f2be394544..5a9899170e 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/LocalizedHtmlString.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/LocalizedHtmlString.cs
@@ -24,26 +24,36 @@ namespace Microsoft.AspNet.Mvc.Localization
///
/// Creates an instance of .
///
- /// The name of the string resource.
+ /// The name of the string resource.
/// The string resource.
- /// A flag that indicates if the resource is not found.
- public LocalizedHtmlString(string key, string value, bool isResourceNotFound)
- : this(key, value, isResourceNotFound, arguments: EmptyArguments)
+ public LocalizedHtmlString(string name, string value)
+ : this(name, value, isResourceNotFound: false, arguments: EmptyArguments)
{
}
///
/// Creates an instance of .
///
- /// The name of the string resource.
+ /// The name of the string resource.
+ /// The string resource.
+ /// A flag that indicates if the resource is not found.
+ public LocalizedHtmlString(string name, string value, bool isResourceNotFound)
+ : this(name, value, isResourceNotFound, arguments: EmptyArguments)
+ {
+ }
+
+ ///
+ /// Creates an instance of .
+ ///
+ /// The name of the string resource.
/// The string resource.
/// A flag that indicates if the resource is not found.
/// The values to format the with.
- public LocalizedHtmlString(string key, string value, bool isResourceNotFound, params object[] arguments)
+ public LocalizedHtmlString(string name, string value, bool isResourceNotFound, params object[] arguments)
{
- if (key == null)
+ if (name == null)
{
- throw new ArgumentNullException(nameof(key));
+ throw new ArgumentNullException(nameof(name));
}
if (value == null)
@@ -56,7 +66,7 @@ namespace Microsoft.AspNet.Mvc.Localization
throw new ArgumentNullException(nameof(arguments));
}
- Key = key;
+ Name = name;
Value = value;
IsResourceNotFound = isResourceNotFound;
_arguments = arguments;
@@ -65,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Localization
///
/// The name of the string resource.
///
- public string Key { get; }
+ public string Name { get; }
///
/// The string resource.
diff --git a/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs b/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs
index a9dc3b8eda..c45b038d38 100644
--- a/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs
+++ b/src/Microsoft.AspNet.Mvc.Localization/ViewLocalizer.cs
@@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.Localization
}
///
- public virtual LocalizedString this[string key]
+ public virtual LocalizedHtmlString this[string key]
{
get
{
@@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.Localization
}
///
- public virtual LocalizedString this[string key, params object[] arguments]
+ public virtual LocalizedHtmlString this[string key, params object[] arguments]
{
get
{
@@ -76,17 +76,16 @@ namespace Microsoft.AspNet.Mvc.Localization
public LocalizedString GetString(string name, params object[] values) => _localizer.GetString(name, values);
///
- public LocalizedHtmlString Html(string key) => _localizer.Html(key);
+ public IHtmlLocalizer WithCulture(CultureInfo culture) => _localizer.WithCulture(culture);
///
- public LocalizedHtmlString Html(string key, params object[] arguments) => _localizer.Html(key, arguments);
-
- ///
- public IStringLocalizer WithCulture(CultureInfo culture) => _localizer.WithCulture(culture);
-
- ///
- IHtmlLocalizer IHtmlLocalizer.WithCulture(CultureInfo culture) => _localizer.WithCulture(culture);
+ public IEnumerable GetAllStrings(bool includeParentCultures) =>
+ _localizer.GetAllStrings(includeParentCultures);
+ ///
+ /// Apply the specified .
+ ///
+ /// The .
public void Contextualize(ViewContext viewContext)
{
if (viewContext == null)
@@ -95,16 +94,12 @@ namespace Microsoft.AspNet.Mvc.Localization
}
var baseName = viewContext.View.Path.Replace('/', '.').Replace('\\', '.');
- if (baseName.StartsWith("."))
+ if (baseName.StartsWith(".", StringComparison.OrdinalIgnoreCase))
{
baseName = baseName.Substring(1);
}
_localizer = _localizerFactory.Create(baseName, _applicationName);
}
-
- ///
- public IEnumerable GetAllStrings(bool includeAncestorCultures) =>
- _localizer.GetAllStrings(includeAncestorCultures);
}
}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerOfTTest.cs b/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerOfTTest.cs
index fe2d996019..357d85e7ed 100644
--- a/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerOfTTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerOfTTest.cs
@@ -14,10 +14,10 @@ namespace Microsoft.AspNet.Mvc.Localization.Test
public class HtmlLocalizerOfTTest
{
[Fact]
- public void HtmlLocalizerOfTTest_UseIndexer_ReturnsLocalizedString()
+ public void HtmlLocalizerOfTTest_UseIndexer_ReturnsLocalizedHtmlString()
{
// Arrange
- var localizedString = new LocalizedString("Hello", "Bonjour");
+ var localizedString = new LocalizedHtmlString("Hello", "Bonjour");
var htmlLocalizer = new Mock();
htmlLocalizer.Setup(h => h["Hello"]).Returns(localizedString);
@@ -36,13 +36,13 @@ namespace Microsoft.AspNet.Mvc.Localization.Test
}
[Fact]
- public void HtmlLocalizerOfTTest_UseIndexerWithArguments_ReturnsLocalizedString()
+ public void HtmlLocalizerOfTTest_UseIndexerWithArguments_ReturnsLocalizedHtmlString()
{
// Arrange
var applicationEnvironment = new Mock();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
- var localizedString = new LocalizedString("Hello", "Bonjour test");
+ var localizedString = new LocalizedHtmlString("Hello", "Bonjour test");
var htmlLocalizer = new Mock();
htmlLocalizer.Setup(h => h["Hello", "test"]).Returns(localizedString);
diff --git a/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerTest.cs b/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerTest.cs
index 2ff1bc919f..be2a8c53fe 100644
--- a/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Localization.Test/HtmlLocalizerTest.cs
@@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Localization.Test
public class HtmlLocalizerTest
{
[Fact]
- public void HtmlLocalizer_UseIndexer_ReturnsLocalizedString()
+ public void HtmlLocalizer_UseIndexer_ReturnsLocalizedHtmlString()
{
// Arrange
var localizedString = new LocalizedString("Hello", "Bonjour");
@@ -27,28 +27,30 @@ namespace Microsoft.AspNet.Mvc.Localization.Test
var htmlLocalizer = new HtmlLocalizer(stringLocalizer.Object);
// Act
- var actualLocalizedString = htmlLocalizer["Hello"];
+ var actualLocalizedHtmlString = htmlLocalizer["Hello"];
// Assert
- Assert.Equal(localizedString, actualLocalizedString);
+ Assert.Equal(localizedString.Name, actualLocalizedHtmlString.Name);
+ Assert.Equal(localizedString.Value, actualLocalizedHtmlString.Value);
}
[Fact]
- public void HtmlLocalizer_UseIndexerWithArguments_ReturnsLocalizedString()
+ public void HtmlLocalizer_UseIndexerWithArguments_ReturnsLocalizedHtmlString()
{
// Arrange
var localizedString = new LocalizedString("Hello", "Bonjour test");
var stringLocalizer = new Mock();
- stringLocalizer.Setup(s => s["Hello", "test"]).Returns(localizedString);
+ stringLocalizer.Setup(s => s["Hello"]).Returns(localizedString);
var htmlLocalizer = new HtmlLocalizer(stringLocalizer.Object);
// Act
- var actualLocalizedString = htmlLocalizer["Hello", "test"];
+ var actualLocalizedHtmlString = htmlLocalizer["Hello", "test"];
// Assert
- Assert.Equal(localizedString, actualLocalizedString);
+ Assert.Equal(localizedString.Name, actualLocalizedHtmlString.Name);
+ Assert.Equal(localizedString.Value, actualLocalizedHtmlString.Value);
}
public static IEnumerable