0
我需要修補一個字典的值與另一個添加新的密鑰。我需要保存新的密鑰並替換現有的密鑰才能完成補丁功能。必須有我無法訪問的現有映射。或者我應該寫什麼映射配置文件?C#詞典到詞典自動翻譯
[Test]
public void DictionaryMapping()
{
// Arrange
var write = new Dictionary<string, object>
{
{ "Key1", 100 },
{ "Key2", true }
};
var patch = new Dictionary<string, object>
{
{ "Key2", false },
{ "Key3", "Additional"}
};
// Act
Mapper.Map(patch, write);
// Assert
Assert.That(write["Key1"], Is.EqualTo(100));
Assert.That(write["Key2"], Is.EqualTo(false));
Assert.That(write["Key3"], Is.EqualTo("Additional"));
}