mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
refactor(core-tests): 显式指定字符串字典比较器
- 补充 LocalizationTableTests 中 string key Dictionary 的 Ordinal comparer - 补充 QueryCoroutineExtensionsTests 中 Metadata 字典的 Ordinal comparer 并保持测试语义不变
This commit is contained in:
parent
2a9e9f26c7
commit
f67b2cedb2
@ -254,7 +254,7 @@ public class QueryCoroutineExtensionsTests
|
||||
{
|
||||
Name = "ComplexName",
|
||||
Values = new List<int> { 1, 2, 3 },
|
||||
Metadata = new Dictionary<string, object> { { "key", "value" } }
|
||||
Metadata = new Dictionary<string, object>(StringComparer.Ordinal) { { "key", "value" } }
|
||||
};
|
||||
|
||||
ComplexResult? receivedResult = null;
|
||||
@ -362,7 +362,7 @@ internal class ComplexQuery : IQuery<ComplexResult>
|
||||
private IArchitectureContext? _context;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public List<int> Values { get; set; } = new();
|
||||
public Dictionary<string, object> Metadata { get; set; } = new();
|
||||
public Dictionary<string, object> Metadata { get; set; } = new(StringComparer.Ordinal);
|
||||
|
||||
public void SetContext(IArchitectureContext context)
|
||||
{
|
||||
@ -388,4 +388,4 @@ internal class ComplexResult
|
||||
public string ProcessedName { get; set; } = string.Empty;
|
||||
public int Sum { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ public class LocalizationTableTests
|
||||
public void GetRawText_ShouldReturnCorrectText()
|
||||
{
|
||||
// Arrange
|
||||
var data = new Dictionary<string, string>
|
||||
var data = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["test.key"] = "Test Value"
|
||||
};
|
||||
@ -26,13 +26,13 @@ public class LocalizationTableTests
|
||||
public void GetRawText_WithFallback_ShouldReturnFallbackValue()
|
||||
{
|
||||
// Arrange
|
||||
var fallbackData = new Dictionary<string, string>
|
||||
var fallbackData = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["test.key"] = "Fallback Value"
|
||||
};
|
||||
var fallbackTable = new LocalizationTable("test", "eng", fallbackData);
|
||||
|
||||
var data = new Dictionary<string, string>();
|
||||
var data = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
var table = new LocalizationTable("test", "zhs", data, fallbackTable);
|
||||
|
||||
// Act
|
||||
@ -46,7 +46,7 @@ public class LocalizationTableTests
|
||||
public void ContainsKey_ShouldReturnTrue_WhenKeyExists()
|
||||
{
|
||||
// Arrange
|
||||
var data = new Dictionary<string, string>
|
||||
var data = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["test.key"] = "Test Value"
|
||||
};
|
||||
@ -63,13 +63,13 @@ public class LocalizationTableTests
|
||||
public void Merge_ShouldOverrideExistingValues()
|
||||
{
|
||||
// Arrange
|
||||
var data = new Dictionary<string, string>
|
||||
var data = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["test.key"] = "Original Value"
|
||||
};
|
||||
var table = new LocalizationTable("test", "eng", data);
|
||||
|
||||
var overrides = new Dictionary<string, string>
|
||||
var overrides = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["test.key"] = "Override Value"
|
||||
};
|
||||
@ -81,4 +81,4 @@ public class LocalizationTableTests
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo("Override Value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user