32 lines
882 B
C#
32 lines
882 B
C#
using Microsoft.Extensions.Localization;
|
|
using Moq;
|
|
using DigitalData.Core.API;
|
|
|
|
namespace DigitalData.Core.Tests.API
|
|
{
|
|
[TestFixture]
|
|
public class StringLocalizerExtensionsTests
|
|
{
|
|
[Test]
|
|
public void ToDynamic_ShouldReturnDynamicObject_WithLocalizedStrings()
|
|
{
|
|
// Arrange
|
|
var localizedStrings = new List<LocalizedString>
|
|
{
|
|
new ("Key1", "Value1"),
|
|
new ("Key2", "Value2"),
|
|
};
|
|
|
|
var mockLocalizer = new Mock<IStringLocalizer>();
|
|
mockLocalizer.Setup(l => l.GetAllStrings(It.IsAny<bool>())).Returns(localizedStrings);
|
|
|
|
// Act
|
|
dynamic result = mockLocalizer.Object.ToDynamic();
|
|
|
|
// Assert
|
|
Assert.AreEqual("Value1", result.Key1);
|
|
Assert.AreEqual("Value2", result.Key2);
|
|
}
|
|
}
|
|
}
|