Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Extra test
  • Loading branch information
tarekgh committed Jan 23, 2023
commit 149393532a4de9393aa9faa1a282f679fb68a47f
Original file line number Diff line number Diff line change
Expand Up @@ -1832,5 +1832,25 @@ public void TestOptionsWithDifferentCollectionInterfaces()
Assert.Equal(2, options.UnInstantiatedIReadOnlyCollection.Count());
Assert.Equal(new string[] { "r", "e" }, options.UnInstantiatedIReadOnlyCollection);
}

[Fact]
public void TestMutatingDictionaryValues()
{
IConfiguration config = new ConfigurationBuilder()
.AddInMemoryCollection()
.Build();

config["Key:0"] = "NewValue";
var dict = new Dictionary<string, string[]>() { { "Key", new[] { "InitialValue" } } };

Assert.Equal(1, dict["Key"].Length);
Assert.Equal("InitialValue", dict["Key"][0]);

// Binding will accumulate to the values inside the dictionary.
config.Bind(dict);
Assert.Equal(2, dict["Key"].Length);
Assert.Equal("InitialValue", dict["Key"][0]);
Assert.Equal("NewValue", dict["Key"][1]);
}
}
}